@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,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { type ScrollViewProps, type StyleProp, type ViewStyle } from 'react-native';
3
- import { type ScreenHeaderControlProps } from './screen-header.js';
3
+ import { type HeaderCloseProps, type ScreenHeaderControlProps } from './screen-header.js';
4
4
  import { type Figure } from './figure.js';
5
5
  /** A number the host supplies as a number so it updates place by place: `{value:0.53,options:{style:'currency',currency:'USD'}}`, or Leverage as `{value:40,suffix:'×'}`. `null` reads as unknown. `formattedValue` is the host's own text for it, still moving place by place. */
6
6
  export type PositionBlockFigure = Figure;
@@ -64,8 +64,8 @@ export interface PositionBlockHeaderProps {
64
64
  stickyHeaderBackground?: string;
65
65
  /** Pressable props for Back, such as `{android_disableSound: true}`. */
66
66
  backProps?: ScreenHeaderControlProps;
67
- /** Pressable props for Close. */
68
- closeProps?: ScreenHeaderControlProps;
67
+ /** Pressable props for Close; `disabled` draws it unavailable. */
68
+ closeProps?: HeaderCloseProps;
69
69
  testID?: string;
70
70
  }
71
71
  export interface PositionBlockProps {
@@ -97,8 +97,8 @@ export interface PositionBlockProps {
97
97
  scrollComponent?: React.ComponentType<ScrollViewProps>;
98
98
  /** Pressable props for the header's Back, such as `{android_disableSound: true}`. */
99
99
  backProps?: ScreenHeaderControlProps;
100
- /** Pressable props for the header's Close. */
101
- closeProps?: ScreenHeaderControlProps;
100
+ /** Pressable props for the header's Close; `disabled` draws it unavailable. */
101
+ closeProps?: HeaderCloseProps;
102
102
  testID?: string;
103
103
  }
104
104
  /** 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. */
@@ -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,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { type ScrollViewProps } from 'react-native';
2
3
  import { type Figure } from './figure.js';
3
4
  import type { AssetArtwork } from './asset-balance-row.js';
4
5
  export type { AssetArtwork } from './asset-balance-row.js';
@@ -60,7 +61,15 @@ export interface ProfileBlockProps {
60
61
  sections: readonly ProfileSection[];
61
62
  /** Host content under the sections on the block's inset, such as legal links. */
62
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;
63
72
  testID?: string;
64
73
  }
65
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. */
66
- export declare function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, 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,6 +1,7 @@
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 React from 'react';
3
3
  import { Image, Pressable, View } from 'react-native';
4
+ import { StickyHeaderLayout } from './sticky-header.js';
4
5
  import { useColors, useFills, useHIG, useMessages, useNumberLocale, usePresentNumber } from './provider.js';
5
6
  import { Text } from './surface.js';
6
7
  import { Button } from './button.js';
@@ -39,10 +40,14 @@ function ProfileListRow({ row }) {
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 });
40
41
  }
41
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. */
42
- export function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, testID }) {
43
+ export function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, stickyHeader, stickyHeaderBackground, scrollComponent, headingId, testID }) {
43
44
  const colors = useColors(), fills = useFills(), t = useMessages(), { direction } = useHIG();
44
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) }));
45
46
  const shown = sections.filter(section => section.rows.length > 0);
46
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 });
47
- 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: [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', 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] });
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] });
48
53
  }
@@ -45,7 +45,9 @@ export interface HIGProviderProps extends Partial<Omit<HIGContext, 'messages'>>
45
45
  }
46
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. */
47
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;
48
+ export declare const useHIG: () => HIGContext & {
49
+ provided?: boolean;
50
+ };
49
51
  /** Number options with the nearest provider's `numberFormat` merged under them; only currency formats change. */
50
52
  export declare function usePresentNumber(): <T extends Intl.NumberFormatOptions | undefined>(options: T) => T;
51
53
  /** The locale numbers are formatted in: the nearest provider's `numberFormat.locale`, else its `locale`. */
@@ -65,4 +67,5 @@ export declare function useColorSpace(): HIGColorSpace;
65
67
  export declare function useBrandColors(): Readonly<Record<HIGTableColorRole, string>>;
66
68
  /** Complete built-in copy for the nearest HIGProvider: host translations over the English defaults. */
67
69
  export declare function useMessages(): HIGMessages;
68
- 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];
@@ -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, numberFormat }) {
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,7 +41,10 @@ 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, numberFormat: numberFormat ?? parent.numberFormat }, 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);
37
50
  /** Number options with the nearest provider's `numberFormat` merged under them; only currency formats change. */
@@ -51,21 +64,30 @@ export function useColorSpace() { return useContext(Context).colorSpace === 'dis
51
64
  export function useBrandColors() { return colorTable(useContext(Context).colorSpace); }
52
65
  /** Complete built-in copy for the nearest HIGProvider: host translations over the English defaults. */
53
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. */
54
68
  export function useControllable(value, initial, onChange, intent = 'selection') {
55
69
  const [internal, setInternal] = useState(initial);
56
- 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]);
57
79
  const { feedback } = useHIG();
58
80
  const id = useId();
59
81
  const sequence = useRef(0);
60
82
  const pending = useRef(null);
61
83
  useEffect(() => { const request = pending.current; if (!request)
62
- return; pending.current = null; if (Object.is(current, request.value)) {
84
+ return; pending.current = null; if (intent && Object.is(current, request.value)) {
63
85
  try {
64
86
  feedback?.emit({ id: `${id}/${++sequence.current}`, source: id, intent, origin: 'native' });
65
87
  }
66
88
  catch { /* Effects remain optional. */ }
67
89
  } });
68
90
  return [current, (next) => { if (Object.is(current, next))
69
- return; pending.current = { value: next }; if (value === undefined)
91
+ return; pending.current = { value: next }; if (!controlled)
70
92
  setInternal(next); onChange?.(next); }];
71
93
  }
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { type StyleProp, type ViewStyle } from 'react-native';
3
+ import { type QRErrorCorrection } from '@bloxwap/hig/contracts/qr';
4
+ export type { QRErrorCorrection } from '@bloxwap/hig/contracts/qr';
5
+ export interface QRCodeProps {
6
+ /** The text to encode: an address, a payment URI, a link. Digits pack tightest, then upper-case alphanumerics, then UTF-8. A value too long for a QR code draws an empty square. */
7
+ value: string;
8
+ /** Edge of the square in dp, quiet zone included; default 196. */
9
+ size?: number;
10
+ /** Drawn over the centre, which is cleared of modules: an image URL, or a node such as a token mark laid out in the arena's box. */
11
+ arena?: React.ReactNode;
12
+ /** Error correction level. Defaults to `high` with an arena, which covers part of the code, and `medium` without. With an arena, `low` and `medium` are raised to `quartile` so the code still reads. */
13
+ errorCorrection?: QRErrorCorrection;
14
+ /** Colour of the modules. Defaults to the provider's `text` role. */
15
+ color?: string;
16
+ /** Colour of the tile behind the code. Defaults to the provider's `background` role; `'none'` draws no tile, for a code that sits on the host's own surface. */
17
+ background?: string;
18
+ /** Clear modules kept on every side, inside `size`; default 4, the margin scanners expect. Pass 0 only where the host keeps that margin itself. */
19
+ quietZone?: number;
20
+ /** Accessible name. Defaults to the built-in “QR code”. */
21
+ label?: string;
22
+ /** Hides the code from assistive technology, for a host that names it on an element of its own. */
23
+ decorative?: boolean;
24
+ /** Also the prefix of `-code` (the drawing) and `-arena` (the image or node in the centre). */
25
+ testID?: string;
26
+ style?: StyleProp<ViewStyle>;
27
+ }
28
+ /**
29
+ * A QR code in the Cuer style: round modules, rounded finder patterns and an optional arena in the centre. HIG encodes the
30
+ * value itself; the drawing is one `react-native-svg` path, so the only peer is `react-native-svg`. The value is encoded once
31
+ * per `value`, `errorCorrection` and arena; `size`, the colours and the quiet zone only change props of the drawing.
32
+ */
33
+ export declare function QRCode({ value, size, arena, errorCorrection, color, background, quietZone, label, decorative, testID, style }: QRCodeProps): React.JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { Image, StyleSheet, View } from 'react-native';
4
+ import Svg, { Path, Rect } from 'react-native-svg';
5
+ import { QR_QUIET_ZONE, qrCodeGeometry, qrFrame } from '@bloxwap/hig/contracts/qr';
6
+ import { useColors, useMessages } from './provider.js';
7
+ const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
8
+ const drawn = (node) => node != null && node !== false && node !== true && node !== '';
9
+ // Centred rather than offset from an edge, so a right-to-left layout cannot move the arena off the cleared square.
10
+ const styles = StyleSheet.create({ centre: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0, alignItems: 'center', justifyContent: 'center' }, arena: { overflow: 'hidden', alignItems: 'center', justifyContent: 'center' } });
11
+ /**
12
+ * A QR code in the Cuer style: round modules, rounded finder patterns and an optional arena in the centre. HIG encodes the
13
+ * value itself; the drawing is one `react-native-svg` path, so the only peer is `react-native-svg`. The value is encoded once
14
+ * per `value`, `errorCorrection` and arena; `size`, the colours and the quiet zone only change props of the drawing.
15
+ */
16
+ export function QRCode({ value, size = 196, arena, errorCorrection, color, background, quietZone = QR_QUIET_ZONE, label, decorative = false, testID, style }) {
17
+ const colors = useColors();
18
+ const t = useMessages();
19
+ const withArena = drawn(arena);
20
+ const geometry = useMemo(() => qrCodeGeometry(value, { errorCorrection, arena: withArena }), [value, errorCorrection, withArena]);
21
+ const frame = useMemo(() => geometry ? qrFrame(geometry, size, quietZone) : null, [geometry, size, quietZone]);
22
+ const tile = background === 'none' || background === 'transparent' ? null : background ?? colors.background;
23
+ const named = !decorative && geometry !== null;
24
+ const box = frame?.arena;
25
+ const access = named ? { accessible: true, accessibilityRole: 'image', accessibilityLabel: label ?? t.qrCode } : hidden;
26
+ const codeID = testID ? `${testID}-code` : undefined, arenaID = testID ? `${testID}-arena` : undefined;
27
+ const boxStyle = box ? { width: box.edge, height: box.edge, borderRadius: box.corner } : undefined;
28
+ return _jsxs(View, { ...access, testID: testID, style: [{ width: size, height: size }, style], children: [_jsxs(Svg, { width: size, height: size, viewBox: frame?.viewBox, accessible: false, testID: codeID, children: [tile && frame ? _jsx(Rect, { x: -frame.quietZone, y: -frame.quietZone, width: frame.span, height: frame.span, rx: frame.tileRadius, fill: tile }) : null, geometry ? _jsx(Path, { d: geometry.path, fill: color ?? colors.text }) : null] }), box ? _jsx(View, { ...hidden, pointerEvents: 'none', style: styles.centre, children: typeof arena === 'string' ? _jsx(Image, { source: { uri: arena }, testID: arenaID, style: boxStyle }) : _jsx(View, { testID: arenaID, style: [styles.arena, boxStyle], children: arena }) }) : null] });
29
+ }
@@ -1,13 +1,20 @@
1
1
  import React from 'react';
2
2
  import { type ScrollViewProps } from 'react-native';
3
- import type { ChoicesProps } from './selection-types.js';
3
+ import type { Choice, ChoicesProps } from './selection-types.js';
4
+ import type { ScreenHeaderControlProps } from './screen-header.js';
4
5
  export declare function RadioGroup({ label, options, value, defaultValue, disabled, onValueChange }: ChoicesProps): React.JSX.Element;
5
6
  /** Equal-width choices with one interruptible selection indicator. The track is the dark well and the selected segment the lighter fill; the control is 44dp tall (36 compact). */
6
- export interface SegmentedControlProps extends ChoicesProps {
7
- hideLabel?: boolean;
7
+ /** One segment. `testID` is the segment's test ID, in place of `<group testID>-<value>`. */
8
+ export interface SegmentedControlOption extends Choice {
8
9
  testID?: string;
9
10
  }
10
- export declare function SegmentedControl({ label, options, value, defaultValue, disabled, hideLabel, testID, onValueChange }: SegmentedControlProps): React.JSX.Element;
11
+ export interface SegmentedControlProps extends Omit<ChoicesProps, 'options'> {
12
+ options: readonly SegmentedControlOption[]; /** Keeps `label` as the group's accessible name but does not draw it, for a control whose heading or row already names it. */
13
+ hideLabel?: boolean; /** Test ID of the group; each segment takes `<testID>-<value>`, such as `trade-share-mode-video`, unless the option sets its own `testID`. */
14
+ testID?: string; /** Pressable props for every segment, such as `{android_disableSound: true}` when the host plays its own sound. HIG keeps its own name, role, state, target and press. */
15
+ segmentProps?: ScreenHeaderControlProps;
16
+ }
17
+ export declare function SegmentedControl({ label, options, value, defaultValue, disabled, hideLabel, testID, segmentProps, onValueChange }: SegmentedControlProps): React.JSX.Element;
11
18
  export interface FilterOption {
12
19
  value: string;
13
20
  label: string;
@@ -21,7 +28,12 @@ export interface FilterProps {
21
28
  defaultValue?: string;
22
29
  disabled?: boolean;
23
30
  onValueChange?: (value: string) => void; /** The horizontal scroll view the capsules sit in, such as a sheet library's ScrollView that keeps sideways drags from the sheet. It receives the same props as React Native's `ScrollView`, which is the default. */
24
- scrollComponent?: React.ComponentType<ScrollViewProps>;
31
+ scrollComponent?: React.ComponentType<ScrollViewProps>; /** Units the row scrolls out past its container on each side, so the capsules are cut by the container's edge, while the first and last capsule rest this far in: pass the container's side padding. Default 0. */
32
+ bleed?: number;
25
33
  }
26
- /** A horizontal, scrolling row of single-choice filter chips. The selected chip inverts and its circle shows a check that animates in. */
27
- export declare function Filter({ label, options, value, defaultValue, disabled, onValueChange, scrollComponent: Scroll }: FilterProps): React.JSX.Element;
34
+ /**
35
+ * A horizontal, scrolling row of single-choice filter chips. The selected chip inverts and its circle shows a check that animates in.
36
+ * The row scrolls the selected chip fully into view on mount and whenever the selection changes, through the scroll view's
37
+ * `scrollTo` (a host `scrollComponent` receives the ref and `onLayout`/`onScroll`; one without `scrollTo` simply does not scroll).
38
+ */
39
+ export declare function Filter({ label, options, value, defaultValue, disabled, onValueChange, scrollComponent, bleed }: FilterProps): React.JSX.Element;