@bloxwap/hig 0.5.2 → 0.7.0

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 (199) hide show
  1. package/README.md +1 -1
  2. package/chart/README.md +1 -1
  3. package/contracts/README.md +1 -1
  4. package/contracts/dist/index.d.ts +16 -0
  5. package/contracts/dist/index.js +22 -0
  6. package/contracts/dist/messages.d.ts +37 -4
  7. package/contracts/dist/messages.js +13 -2
  8. package/feedback/README.md +1 -1
  9. package/native/README.md +1 -1
  10. package/native/dist/account-block.d.ts +92 -0
  11. package/native/dist/account-block.js +61 -0
  12. package/native/dist/animated-number-model.d.ts +7 -1
  13. package/native/dist/animated-number-model.js +50 -1
  14. package/native/dist/animated-number.d.ts +3 -1
  15. package/native/dist/animated-number.js +8 -5
  16. package/native/dist/asset-balance-row.d.ts +36 -0
  17. package/native/dist/asset-balance-row.js +26 -0
  18. package/native/dist/bar-mark.d.ts +57 -0
  19. package/native/dist/bar-mark.js +48 -0
  20. package/native/dist/bar-pnl.d.ts +50 -0
  21. package/native/dist/bar-pnl.js +60 -0
  22. package/native/dist/blocks.d.ts +38 -0
  23. package/native/dist/blocks.js +42 -0
  24. package/native/dist/button.js +3 -1
  25. package/native/dist/data.d.ts +1 -1
  26. package/native/dist/data.js +6 -4
  27. package/native/dist/field.d.ts +14 -5
  28. package/native/dist/field.js +33 -8
  29. package/native/dist/figure.d.ts +23 -0
  30. package/native/dist/figure.js +10 -0
  31. package/native/dist/icons.d.ts +8 -0
  32. package/native/dist/icons.js +4 -0
  33. package/native/dist/language-block.d.ts +35 -0
  34. package/native/dist/language-block.js +30 -0
  35. package/native/dist/list-group.d.ts +60 -0
  36. package/native/dist/list-group.js +85 -0
  37. package/native/dist/manage-position-block.d.ts +95 -0
  38. package/native/dist/manage-position-block.js +82 -0
  39. package/native/dist/market-row.d.ts +46 -0
  40. package/native/dist/market-row.js +30 -0
  41. package/native/dist/notifications-block.d.ts +53 -0
  42. package/native/dist/notifications-block.js +22 -0
  43. package/native/dist/pickers.d.ts +35 -5
  44. package/native/dist/pickers.js +21 -9
  45. package/native/dist/position-block.d.ts +107 -0
  46. package/native/dist/position-block.js +55 -0
  47. package/native/dist/profile-block.d.ts +66 -0
  48. package/native/dist/profile-block.js +48 -0
  49. package/native/dist/provider.d.ts +9 -3
  50. package/native/dist/provider.js +7 -3
  51. package/native/dist/radio-group.d.ts +9 -3
  52. package/native/dist/radio-group.js +4 -5
  53. package/native/dist/recipes.d.ts +6 -46
  54. package/native/dist/recipes.js +6 -33
  55. package/native/dist/reward-block.d.ts +122 -0
  56. package/native/dist/reward-block.js +53 -0
  57. package/native/dist/screen-header.d.ts +49 -0
  58. package/native/dist/screen-header.js +29 -0
  59. package/native/dist/selection.d.ts +2 -2
  60. package/native/dist/setting-header.d.ts +2 -0
  61. package/native/dist/setting-header.js +2 -0
  62. package/native/dist/setting-switch.d.ts +31 -0
  63. package/native/dist/setting-switch.js +20 -0
  64. package/native/dist/signals-block.d.ts +61 -0
  65. package/native/dist/signals-block.js +26 -0
  66. package/native/dist/sound-haptics-block.d.ts +66 -0
  67. package/native/dist/sound-haptics-block.js +32 -0
  68. package/native/dist/status.d.ts +6 -5
  69. package/native/dist/status.js +5 -5
  70. package/native/dist/sticky-header.d.ts +28 -0
  71. package/native/dist/sticky-header.js +21 -0
  72. package/native/dist/surface.d.ts +3 -1
  73. package/native/dist/surface.js +2 -1
  74. package/native/dist/{swap-panel.d.ts → swap-panel-block.d.ts} +8 -3
  75. package/native/dist/{swap-panel.js → swap-panel-block.js} +13 -8
  76. package/native/dist/swap-parts.d.ts +5 -3
  77. package/native/dist/swap-parts.js +2 -2
  78. package/native/dist/swap-shared.d.ts +6 -0
  79. package/native/dist/swap-sheet.d.ts +4 -4
  80. package/native/dist/swap-sheet.js +4 -4
  81. package/native/dist/swap-views.d.ts +1 -1
  82. package/native/dist/swap-views.js +9 -7
  83. package/native/dist/switch-row.d.ts +3 -2
  84. package/native/dist/switch-row.js +5 -3
  85. package/native/dist/switch.d.ts +4 -2
  86. package/native/dist/switch.js +3 -3
  87. package/native/dist/target-block.d.ts +110 -0
  88. package/native/dist/target-block.js +74 -0
  89. package/native/dist/token-action-block.d.ts +47 -0
  90. package/native/dist/token-action-block.js +28 -0
  91. package/native/dist/trade-history-detail-block.d.ts +84 -0
  92. package/native/dist/trade-history-detail-block.js +46 -0
  93. package/native/dist/trade-history-list-block.d.ts +110 -0
  94. package/native/dist/trade-history-list-block.js +64 -0
  95. package/native/dist/wallet-address-core.d.ts +25 -0
  96. package/native/dist/wallet-address-core.js +31 -0
  97. package/native/dist/wallet-address.d.ts +6 -10
  98. package/native/dist/wallet-address.js +16 -20
  99. package/native-fonts/README.md +1 -1
  100. package/og-fonts/README.md +1 -1
  101. package/package.json +266 -41
  102. package/react/README.md +1 -1
  103. package/react/dist/animated-number-model.d.ts +6 -0
  104. package/react/dist/animated-number-model.js +33 -0
  105. package/react/dist/animated-number.d.ts +5 -1
  106. package/react/dist/animated-number.js +12 -8
  107. package/react/dist/asset-balance-row.d.ts +35 -0
  108. package/react/dist/asset-balance-row.js +18 -0
  109. package/react/dist/bar-mark.d.ts +38 -0
  110. package/react/dist/bar-mark.js +23 -0
  111. package/react/dist/bar-pnl.d.ts +49 -0
  112. package/react/dist/bar-pnl.js +45 -0
  113. package/react/dist/blocks/account-block.d.ts +92 -0
  114. package/react/dist/blocks/account-block.js +62 -0
  115. package/react/dist/blocks/language-block.d.ts +36 -0
  116. package/react/dist/blocks/language-block.js +52 -0
  117. package/react/dist/blocks/manage-position-block.d.ts +93 -0
  118. package/react/dist/blocks/manage-position-block.js +47 -0
  119. package/react/dist/blocks/market-row.d.ts +36 -0
  120. package/react/dist/blocks/market-row.js +16 -0
  121. package/react/dist/blocks/notifications-block.d.ts +46 -0
  122. package/react/dist/blocks/notifications-block.js +17 -0
  123. package/react/dist/{recipes → blocks}/pickers.d.ts +32 -4
  124. package/react/dist/{recipes → blocks}/pickers.js +35 -11
  125. package/react/dist/blocks/position-block.d.ts +72 -0
  126. package/react/dist/blocks/position-block.js +25 -0
  127. package/react/dist/blocks/profile-block.d.ts +71 -0
  128. package/react/dist/blocks/profile-block.js +41 -0
  129. package/react/dist/blocks/reward-block.d.ts +120 -0
  130. package/react/dist/blocks/reward-block.js +34 -0
  131. package/react/dist/blocks/screen-header.d.ts +33 -0
  132. package/react/dist/blocks/screen-header.js +20 -0
  133. package/react/dist/blocks/setting-switch.d.ts +23 -0
  134. package/react/dist/blocks/setting-switch.js +12 -0
  135. package/react/dist/blocks/signals-block.d.ts +54 -0
  136. package/react/dist/blocks/signals-block.js +15 -0
  137. package/react/dist/blocks/sound-haptics-block.d.ts +59 -0
  138. package/react/dist/blocks/sound-haptics-block.js +22 -0
  139. package/react/dist/blocks/sticky-header.d.ts +9 -0
  140. package/react/dist/blocks/sticky-header.js +43 -0
  141. package/react/dist/blocks/swap/amount-card.js +8 -0
  142. package/react/dist/{recipes → blocks}/swap/picker.d.ts +1 -1
  143. package/react/dist/{recipes → blocks}/swap/picker.js +4 -4
  144. package/react/dist/{recipes → blocks}/swap/settings.js +2 -2
  145. package/react/dist/{recipes → blocks}/swap/shared.d.ts +8 -1
  146. package/react/dist/{recipes → blocks}/swap/shared.js +7 -4
  147. package/react/dist/{recipes/swap-panel.d.ts → blocks/swap-panel-block.d.ts} +8 -2
  148. package/react/dist/{recipes/swap-panel.js → blocks/swap-panel-block.js} +9 -7
  149. package/react/dist/{recipes → blocks}/swap-sheet.d.ts +4 -4
  150. package/react/dist/{recipes → blocks}/swap-sheet.js +4 -4
  151. package/react/dist/blocks/target-block.d.ts +103 -0
  152. package/react/dist/blocks/target-block.js +73 -0
  153. package/react/dist/blocks/token-action-block.d.ts +46 -0
  154. package/react/dist/blocks/token-action-block.js +21 -0
  155. package/react/dist/{recipes → blocks}/trade-entry.js +2 -2
  156. package/react/dist/blocks/trade-history-detail-block.d.ts +78 -0
  157. package/react/dist/blocks/trade-history-detail-block.js +17 -0
  158. package/react/dist/blocks/trade-history-list-block.d.ts +67 -0
  159. package/react/dist/blocks/trade-history-list-block.js +28 -0
  160. package/react/dist/blocks.d.ts +20 -0
  161. package/react/dist/blocks.js +21 -0
  162. package/react/dist/button.js +6 -4
  163. package/react/dist/data.js +3 -3
  164. package/react/dist/field.d.ts +14 -6
  165. package/react/dist/field.js +19 -8
  166. package/react/dist/figure.d.ts +23 -0
  167. package/react/dist/figure.js +12 -0
  168. package/react/dist/list-group.d.ts +59 -0
  169. package/react/dist/list-group.js +52 -0
  170. package/react/dist/provider.d.ts +40 -3
  171. package/react/dist/provider.js +63 -6
  172. package/react/dist/selection.d.ts +8 -2
  173. package/react/dist/selection.js +11 -6
  174. package/react/dist/styles.css +425 -5
  175. package/react/dist/surface.d.ts +5 -1
  176. package/react/dist/surface.js +1 -1
  177. package/react/dist/wallet-address-core.d.ts +23 -0
  178. package/react/dist/wallet-address-core.js +24 -0
  179. package/react/dist/wallet-address.d.ts +6 -12
  180. package/react/dist/wallet-address.js +5 -16
  181. package/tokens/README.md +1 -1
  182. package/react/dist/recipes/activity-list.d.ts +0 -8
  183. package/react/dist/recipes/activity-list.js +0 -6
  184. package/react/dist/recipes/balance-card.d.ts +0 -6
  185. package/react/dist/recipes/balance-card.js +0 -5
  186. package/react/dist/recipes/code-window.d.ts +0 -4
  187. package/react/dist/recipes/code-window.js +0 -4
  188. package/react/dist/recipes/market-row.d.ts +0 -25
  189. package/react/dist/recipes/market-row.js +0 -8
  190. package/react/dist/recipes/swap/amount-card.js +0 -7
  191. package/react/dist/recipes.d.ts +0 -10
  192. package/react/dist/recipes.js +0 -11
  193. /package/react/dist/{recipes → blocks}/install-command.d.ts +0 -0
  194. /package/react/dist/{recipes → blocks}/install-command.js +0 -0
  195. /package/react/dist/{recipes → blocks}/marketing-hero.d.ts +0 -0
  196. /package/react/dist/{recipes → blocks}/marketing-hero.js +0 -0
  197. /package/react/dist/{recipes → blocks}/swap/amount-card.d.ts +0 -0
  198. /package/react/dist/{recipes → blocks}/swap/settings.d.ts +0 -0
  199. /package/react/dist/{recipes → blocks}/trade-entry.d.ts +0 -0
@@ -1,33 +1,6 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from 'react';
3
- import { Platform } from 'react-native';
4
- import * as en from '@bloxwap/hig/contracts/messages';
5
- import { useColors, useHIG } from './provider.js';
6
- import { Button, Link } from './button.js';
7
- import { Surface, Stack, Heading, Text } from './surface.js';
8
- import { Field, AmountInput } from './field.js';
9
- import { Dialog } from './overlay.js';
10
- import { Row, Usd, Percent, List } from './data.js';
11
- import { Toast, useTransientNotice } from './status.js';
12
- export function MarketRow({ symbol, name, price, change, onSelect }) { return _jsxs(Row, { children: [_jsxs(Button, { intent: 'ghost', onPress: onSelect, children: [name, " (", symbol, ")"] }), _jsx(Usd, { value: price }), _jsx(Percent, { value: change })] }); }
13
- export function BalanceCard({ label, balance, stale }) { const colors = useColors(); return _jsxs(Surface, { style: { gap: 8 }, children: [_jsx(Text, { style: { color: colors.muted, fontSize: 14, lineHeight: 21 }, children: label }), _jsx(Usd, { value: balance, stale: stale, style: { fontSize: 24, lineHeight: 30, fontWeight: '600' } })] }); }
14
- /** The call to action that closes a form sits a double step, 16dp, below it (the Stack gap is 12). */
15
- const formAction = { marginTop: 4 };
16
- /** In a dialog the confirm action is 16dp below the content and 8dp above the dialog's own closing button, which adds 4dp itself. */
17
- const dialogAction = { marginTop: 4, marginBottom: -8 };
18
- export function TradeEntry({ asset, amount, onAmountChange, onConfirm, busy, error, available }) { const { messages } = useHIG(); const [review, setReview] = useState(false); return _jsx(Surface, { children: _jsxs(Stack, { children: [_jsx(Heading, { children: (messages.reviewAssetOrder ?? en.reviewAssetOrder)(asset) }), _jsx(Field, { label: (messages.amountInAsset ?? en.amountInAsset)(asset), description: (messages.availableAmount ?? en.availableAmount)(available), error: error, children: _jsx(AmountInput, { value: amount, onChangeText: onAmountChange, editable: !busy }) }), _jsx(Button, { fullWidth: true, style: formAction, disabled: !amount || !!error, busy: busy, onPress: () => setReview(true), children: messages.reviewOrder ?? en.reviewOrder }), _jsxs(Dialog, { open: review, onOpenChange: setReview, title: messages.confirmOrder ?? en.confirmOrder, description: (messages.confirmOrderDescription ?? en.confirmOrderDescription)(amount, asset), children: [_jsx(Button, { busy: busy, disabled: !!error, style: dialogAction, onPress: onConfirm, children: messages.confirmOrder ?? en.confirmOrder }), error && _jsx(Text, { accessibilityLiveRegion: 'polite', children: error })] })] }) }); }
19
- /** Code and commands stay monospace and left-to-right inside RTL roots. */
20
- function useCodeStyle() { const env = useHIG(); return { fontFamily: env.monoFontFamily ?? Platform.select({ ios: 'Menlo', default: 'monospace' }), writingDirection: 'ltr', textAlign: 'left' }; }
21
- /** A copy outcome shows as a transient toast capsule (about 4s, dismissible) and is announced the way Toast announces any notice. */
22
- export function InstallCommand({ command, onCopy }) {
23
- const { messages } = useHIG();
24
- const { notice, show, dismiss } = useTransientNotice();
25
- const code = useCodeStyle();
26
- return _jsxs(Surface, { style: { gap: 12 }, children: [_jsx(Text, { selectable: true, style: code, children: command }), _jsx(Button, { intent: 'secondary', onPress: () => { Promise.resolve().then(onCopy).then(() => show(messages.copied ?? en.copied, 'success')).catch(() => show(messages.copyFailed ?? en.copyFailed, 'error')); }, children: messages.copyInstallCommand ?? en.copyInstallCommand }), notice && _jsx(Toast, { notices: [notice], onDismiss: dismiss })] });
27
- }
28
- export function CodeWindow({ language, children }) { const code = useCodeStyle(); return _jsxs(Surface, { children: [_jsx(Text, { children: language }), _jsx(Text, { selectable: true, style: code, children: children })] }); }
29
- export function MarketingHero({ title, description, href, cta }) { return _jsxs(Stack, { children: [_jsx(Heading, { children: title }), _jsx(Text, { children: description }), _jsx(Link, { href: href, children: cta })] }); }
30
- export function ActivityList({ items }) { const { messages } = useHIG(); return _jsx(List, { items: items, keyFor: i => i.id, render: i => _jsxs(Row, { children: [_jsx(Text, { children: i.label }), _jsx(Text, { children: i.status })] }), empty: messages.noActivity ?? en.noActivity }); }
31
- export { FromPicker, ToPicker } from './pickers.js';
32
- export { SwapKeypad, SwapCapsule } from './swap-parts.js';
33
- export { SwapPanel, swapAction } from './swap-panel.js';
1
+ /**
2
+ * @deprecated Blocks were called recipes through 0.5.x. Import from `@bloxwap/hig/native/blocks`; this module is removed in the next
3
+ * major release. It exists as a real file so a Jest `moduleNameMapper` that maps `@bloxwap/hig/native/<entry>` to `native/dist/<entry>.js`
4
+ * resolves the old path too.
5
+ */
6
+ export * from './blocks.js';
@@ -0,0 +1,122 @@
1
+ import React from 'react';
2
+ import { type ScrollViewProps } from 'react-native';
3
+ import type { AssetArtwork } from './asset-balance-row.js';
4
+ import { type Figure } from './figure.js';
5
+ /** The promotion above the standings: a prize pool filling towards a goal, or a draw with a top prize. Every word is host text. */
6
+ export interface RewardPromo {
7
+ /** The small capitals line: Season 01. */
8
+ eyebrow: string;
9
+ /** A text link with a chevron on the trailing edge of the eyebrow: Rules. */
10
+ rules?: {
11
+ label: string;
12
+ onSelect: () => void;
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. */
17
+ amountOptions?: Intl.NumberFormatOptions;
18
+ /** The amount the pool is filling towards. Draws the progress bar under the caption. */
19
+ 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 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
+ headline?: React.ReactNode;
24
+ /** Continues the sentence after the headline in the muted colour: Funded by builder fees on every trade. */
25
+ description?: string;
26
+ /** A full-width action under the description: Draws and winners. The host opens its own destination. */
27
+ action?: {
28
+ label: string;
29
+ onSelect: () => void;
30
+ };
31
+ }
32
+ /** A host figure that updates place by place: `{value:1090779, options:{style:'currency',currency:'USD',maximumFractionDigits:0}, suffix:' vol'}`. */
33
+ export type RewardFigure = Figure;
34
+ /** One step of the paging control under the list. */
35
+ export interface RewardPageStep {
36
+ label: string;
37
+ onSelect: () => void;
38
+ disabled?: boolean;
39
+ }
40
+ /** One trader in the standings. */
41
+ export interface RewardEntry {
42
+ id: string;
43
+ rank: number;
44
+ /** A short address, a handle, or the host's word for the viewer. */
45
+ name: string;
46
+ /** An image URL or a host element. Without one the first letters of the name are shown. */
47
+ avatar?: AssetArtwork;
48
+ /** Shows the verified mark after the name. */
49
+ verified?: boolean;
50
+ /** The line under the name: `$1,090,779 vol` as text, or the same as a live figure. */
51
+ detail?: string | RewardFigure;
52
+ /** Points or entries. `null` reads as unknown. */
53
+ score: number | null;
54
+ /** Format of this entry's score, in place of the block's `scoreOptions`, for a prize list where some amounts have cents. */
55
+ scoreOptions?: Intl.NumberFormatOptions;
56
+ /** Marks the viewer's own row: the name and score take the action colour. */
57
+ you?: boolean;
58
+ }
59
+ export interface RewardBlockProps {
60
+ /** Heading: Leaderboard. */
61
+ title: string;
62
+ promo?: RewardPromo;
63
+ /** A choice between standings, such as Upcoming draw and Top winners. `label` names the control. */
64
+ tabs?: {
65
+ label: string;
66
+ options: readonly {
67
+ value: string;
68
+ label: string;
69
+ }[];
70
+ value: string;
71
+ onValueChange: (value: string) => void;
72
+ };
73
+ /** The viewer's own standing, pinned above the list on a tinted row. */
74
+ you?: RewardEntry;
75
+ /** Names the pinned row for assistive technology, read before its rank: Your rank. */
76
+ youLabel?: string;
77
+ /** A muted line between the pinned row and the list, announced when it changes: You're not ranked yet. */
78
+ status?: string;
79
+ /** Host artwork in place of the built-in verified mark, inside the row's one accessible element. */
80
+ verifiedMark?: React.ReactNode;
81
+ /** The `verifiedMark` is a control, such as a badge that opens an explanation: it stays in the accessibility tree, the row's reading then sits on the name and the mark follows as its own element. */
82
+ verifiedMarkInteractive?: boolean;
83
+ /** Draws skeleton rows in place of the entries while the host loads them. */
84
+ loading?: boolean;
85
+ /** Host text that names the skeleton rows for assistive technology: Loading standings. Without it they are only marked busy. */
86
+ loadingLabel?: string;
87
+ /** Paging under the list: Previous and Next as buttons with the host's range between them, such as 1–25. */
88
+ pagination?: {
89
+ previous?: RewardPageStep;
90
+ next?: RewardPageStep;
91
+ label?: string;
92
+ };
93
+ /** Keeps the header pinned while the rest scrolls: the block becomes its own scroll view (`scrollComponent`) with the header as a sticky first child, transparent at rest and filled once the standings scroll under it. Place it in a bounded container, such as a sheet body. */
94
+ stickyHeader?: boolean;
95
+ /** Fill behind the pinned header once rows scroll under it. Defaults to the background role; in a sheet pass the sheet's fill (`useColors().overlay`). */
96
+ stickyHeaderBackground?: string;
97
+ /** Set false to leave the header out, when the host pins its own `ScreenHeader` above the block. The content then starts at the block's top edge. */
98
+ header?: boolean;
99
+ /** The scroll view used with `stickyHeader`, such as a sheet library's own. Defaults to React Native's ScrollView. */
100
+ scrollComponent?: React.ComponentType<ScrollViewProps>;
101
+ /** The column heading over the names: Top 25 by volume. */
102
+ listTitle?: string;
103
+ /** The column heading over the scores: Entries. */
104
+ scoreTitle?: string;
105
+ entries: readonly RewardEntry[];
106
+ /** Format of every score. Defaults to a whole number. An entry's own `scoreOptions` wins. */
107
+ scoreOptions?: Intl.NumberFormatOptions;
108
+ /** Words for the verified mark, read after the name. */
109
+ verifiedLabel?: string;
110
+ /** A line under the list: Entries are provisional until audited. */
111
+ footnote?: string;
112
+ /** Shows Back on the leading edge of the header. */
113
+ onBack?: () => void;
114
+ /** A control on the trailing edge of the header, usually an IconButton that shares. */
115
+ headerAction?: React.ReactNode;
116
+ /** Prefixes every test ID inside the block: `<testID>-header`, `<testID>-back`, `<testID>-title`, `<testID>-row-<id>` and so on. Omitted, they start with `reward`. */
117
+ testID?: string;
118
+ }
119
+ /** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
120
+ export declare function rewardProgress(amount: number | null | undefined, goal: number | null | undefined): number | null;
121
+ /** 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. */
122
+ export declare function RewardBlock({ title, promo, tabs, you, youLabel, status, listTitle, scoreTitle, entries, scoreOptions, verifiedLabel, verifiedMark, verifiedMarkInteractive, loading, loadingLabel, pagination, footnote, onBack, headerAction, stickyHeader, stickyHeaderBackground, scrollComponent, header: showHeader, testID }: RewardBlockProps): React.JSX.Element;
@@ -0,0 +1,53 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Image, Pressable, View } from 'react-native';
3
+ import { formatNumber } from '@bloxwap/hig/contracts';
4
+ import { withAlpha } from '@bloxwap/hig/tokens';
5
+ import { useColors, useFills, useHIG, useNumberLocale, usePresentNumber } from './provider.js';
6
+ import { Surface, Text } from './surface.js';
7
+ import { Button } from './button.js';
8
+ import { SegmentedControl } from './radio-group.js';
9
+ import { ChevronIcon, SeverityIcon } from './icons.js';
10
+ import { AnimatedNumberReadout } from './animated-number.js';
11
+ import { formatNumberReadout } from './animated-number-model.js';
12
+ import { ScreenHeader } from './screen-header.js';
13
+ import { StickyHeaderLayout } from './sticky-header.js';
14
+ import { figureProps } from './figure.js';
15
+ const wholeDollars = { style: 'currency', currency: 'USD', maximumFractionDigits: 0 };
16
+ const whole = { maximumFractionDigits: 0 };
17
+ const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
18
+ const avatar = 40, space = ' ';
19
+ /** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
20
+ export function rewardProgress(amount, goal) {
21
+ return amount == null || goal == null || !Number.isFinite(amount) || !Number.isFinite(goal) || !(goal > 0) ? null : Math.min(1, Math.max(0, amount / goal));
22
+ }
23
+ /** 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
+ const colors = useColors(), fills = useFills(), { direction, monoFontFamily } = useHIG(), locale = useNumberLocale(), present = usePresentNumber();
26
+ const prefix = testID ?? 'reward', tid = (part) => `${prefix}-${part}`;
27
+ const money = promo?.amountOptions ?? wholeDollars, reached = promo ? rewardProgress(promo.amount, promo.goal) : null;
28
+ const caption = typeof promo?.caption === 'function' ? promo.goal !== undefined ? promo.caption(formatNumber(promo.goal, locale, present(money))) : undefined : promo?.caption;
29
+ const caps = { fontFamily: monoFontFamily, fontSize: 12, lineHeight: 16, letterSpacing: 1.5, textTransform: 'uppercase' };
30
+ const standing = (entry, id, style, lead) => {
31
+ 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
+ const said = figure ? formatNumberReadout(figure.value, locale, present(figure.options), figure.formattedValue, figure.prefix, figure.suffix).text : detail;
33
+ const mine = !!entry.you, reading = [lead, String(entry.rank), entry.name, entry.verified && verifiedLabel ? verifiedLabel : null, said, formatNumberReadout(entry.score, locale, present(score)).text].filter(Boolean).join(', ');
34
+ const disc = { width: avatar, height: avatar, borderRadius: avatar / 2, backgroundColor: fills.raised, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' };
35
+ // An interactive host mark stays in the accessibility tree: the row's reading moves to the name, and the mark follows as its own element.
36
+ const split = !!entry.verified && verifiedMark != null && !!verifiedMarkInteractive;
37
+ return _jsxs(View, { testID: id, accessible: !split, accessibilityLabel: split ? undefined : reading, style: { direction, flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 64, paddingVertical: 8, paddingHorizontal: 20, backgroundColor: fills.well, ...style }, children: [_jsx(Text, { ...hidden, style: { minWidth: 24, fontFamily: monoFontFamily, fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.muted }, children: entry.rank }), _jsx(View, { ...hidden, children: typeof entry.avatar === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: entry.avatar }, style: disc }) : _jsx(View, { style: disc, children: entry.avatar ?? _jsx(Text, { maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: entry.name.slice(0, 2) }) }) }), _jsxs(View, { ...(split ? null : hidden), style: { flex: 1, flexShrink: 1, minWidth: 0 }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 6 }, children: [_jsx(Text, { testID: `${id}-name`, accessible: split, accessibilityLabel: split ? reading : undefined, numberOfLines: 1, style: { flexShrink: 1, fontFamily: monoFontFamily, fontSize: 16, lineHeight: 24, fontWeight: '600', color: mine ? colors.action : colors.text }, children: entry.name }), entry.verified ? (verifiedMark != null ? _jsx(View, { testID: `${id}-verified`, children: verifiedMark }) : _jsx(View, { testID: `${id}-verified`, style: { transform: [{ scale: 0.8 }] }, children: _jsx(SeverityIcon, { kind: 'success', color: colors.warning }) })) : null] }), figure ? _jsx(View, { ...hidden, style: { alignItems: 'flex-start' }, children: _jsx(AnimatedNumberReadout, { testID: `${id}-detail`, ...figureProps(figure), tone: 'muted', style: { fontFamily: monoFontFamily, fontSize: 14, lineHeight: 20 } }) })
38
+ : detail ? _jsx(Text, { ...hidden, numberOfLines: 1, style: { fontFamily: monoFontFamily, fontSize: 14, lineHeight: 20, color: colors.muted }, children: detail }) : null] }), _jsx(View, { ...hidden, children: _jsx(AnimatedNumberReadout, { value: entry.score, options: score, tone: mine ? 'positive' : 'text', testID: `${id}-score`, style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) })] }, entry.id);
39
+ };
40
+ // Rows are built here so their test ids are code, not JSX text.
41
+ const pinned = you ? standing({ ...you, you: true }, tid('you'), { marginTop: 16, borderRadius: 20, backgroundColor: withAlpha(colors.action, 0.12) }, youLabel) : null;
42
+ const rows = entries.map(entry => standing(entry, tid(`row-${entry.id}`)));
43
+ const header = _jsx(ScreenHeader, { testID: prefix, title: title, onBack: onBack, action: headerAction });
44
+ const small = { fontSize: 14, lineHeight: 21, color: colors.muted };
45
+ 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
+ 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] });
48
+ if (!showHeader)
49
+ return _jsx(View, { testID: testID, style: { padding: 16, paddingTop: 0 }, children: body });
50
+ if (stickyHeader)
51
+ return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: tid('sticky-header'), header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: body });
52
+ return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [header, body] });
53
+ }
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { View, type PressableProps, type StyleProp, type ViewStyle } from 'react-native';
3
+ export { ChevronIcon } from './icons.js';
4
+ export { useStickyHeaderScroll, type StickyHeaderScroll } from './sticky-header.js';
5
+ /** Pressable props passed through to a header control, such as `android_disableSound` or `onPressIn`. HIG keeps its own name, role, state, target and press. */
6
+ export type ScreenHeaderControlProps = Omit<PressableProps, 'children' | 'onPress' | 'disabled' | 'style' | 'accessibilityLabel' | 'accessibilityRole' | 'accessibilityState' | 'testID'>;
7
+ export interface ScreenHeaderProps {
8
+ /** The heading, centred. Host text. */
9
+ title: string;
10
+ /** Shows Back on the leading edge. */
11
+ onBack?: () => void;
12
+ /** Draws Back unavailable: dimmed, read as disabled and not pressable, for example while a close is being signed. */
13
+ backDisabled?: boolean;
14
+ /** Pressable props for Back, such as `{android_disableSound: true}` when the host plays its own sound. */
15
+ backProps?: ScreenHeaderControlProps;
16
+ /** A control on the trailing edge, usually an `IconButton`. */
17
+ action?: React.ReactNode;
18
+ /** Prefix of the test IDs: `<testID>-header`, `<testID>-back` and `<testID>-title`. Omitted, the header sets none. */
19
+ testID?: string;
20
+ /** Sets `nativeID` on the title, so a sheet around the pane can name itself with `accessibilityLabelledBy` (Android). Omitted, the title has none. */
21
+ headingId?: string;
22
+ /** A ref to the heading's accessible element (the title, or the title and badge as one header), for example to move accessibility focus to it when the pane opens. */
23
+ titleRef?: React.Ref<React.ComponentRef<typeof View>>;
24
+ /** Short host text in a badge beside the title, read as part of the heading after a pause: Demo. */
25
+ badge?: string;
26
+ /** 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
+ hideTitle?: boolean;
28
+ /** 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
+ stickyHeader?: boolean;
30
+ /** With `stickyHeader`: content has scrolled under the header, so it draws its fill. */
31
+ scrolled?: boolean;
32
+ /** 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
+ stickyHeaderBackground?: string;
34
+ /** Style of the header's container, such as padding when it sits in a scroller's sticky slot. */
35
+ style?: StyleProp<ViewStyle>;
36
+ }
37
+ /** The block header's Close control, shared by the blocks that draw one. */
38
+ export declare function HeaderClose({ onClose, label, testID, closeProps }: {
39
+ onClose: () => void;
40
+ label: string;
41
+ testID?: string;
42
+ closeProps?: ScreenHeaderControlProps;
43
+ }): React.JSX.Element;
44
+ /**
45
+ * 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
+ * edge. The settings blocks (Notifications, Signals, Sound & Haptics) draw it; the other native blocks draw a header that matches
47
+ * it. Import it from `@bloxwap/hig/native/screen-header` for a host pane that has no block.
48
+ */
49
+ export declare function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, hideTitle, stickyHeader, scrolled, stickyHeaderBackground, style }: ScreenHeaderProps): React.JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ import { useColors, useHIG, useMessages } from './provider.js';
4
+ import { Text } from './surface.js';
5
+ import { IconButton } from './button.js';
6
+ import { ChevronIcon, CloseIcon } from './icons.js';
7
+ import { Badge } from './status.js';
8
+ import { stickyHeaderFill } from './sticky-header.js';
9
+ export { ChevronIcon } from './icons.js';
10
+ export { useStickyHeaderScroll } from './sticky-header.js';
11
+ /** The block header's Close control, shared by the blocks that draw one. */
12
+ export function HeaderClose({ onClose, label, testID, closeProps }) {
13
+ const colors = useColors();
14
+ return _jsx(IconButton, { ...closeProps, intent: 'ghost', label: label, suppressFeedback: true, testID: testID, onPress: onClose, children: _jsx(CloseIcon, { color: colors.text }) });
15
+ }
16
+ /**
17
+ * The header of a block that is its own screen: Back on the leading edge, the title centred, an optional control on the trailing
18
+ * edge. The settings blocks (Notifications, Signals, Sound & Haptics) draw it; the other native blocks draw a header that matches
19
+ * it. Import it from `@bloxwap/hig/native/screen-header` for a host pane that has no block.
20
+ */
21
+ export function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, hideTitle, stickyHeader, scrolled, stickyHeaderBackground, style }) {
22
+ const colors = useColors(), t = useMessages(), { direction } = useHIG();
23
+ const id = (part) => testID === undefined ? undefined : `${testID}-${part}`;
24
+ // Clear white stays in the accessibility tree where opacity 0 might not; the title keeps its line so the header keeps its height.
25
+ const ink = hideTitle ? '#ffffff00' : colors.text;
26
+ const heading = { textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: ink };
27
+ const fill = stickyHeader ? stickyHeaderFill(!!scrolled, stickyHeaderBackground ?? colors.background) : undefined;
28
+ 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 })] });
29
+ }
@@ -1,8 +1,8 @@
1
1
  export type { Choice, CheckedProps, ChoicesProps } from './selection-types.js';
2
- export { Switch, SwitchRow, type SwitchRowProps } from './switch.js';
2
+ export { Switch, SwitchRow, type SwitchProps, type SwitchRowProps } from './switch.js';
3
3
  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 } from './radio-group.js';
7
+ export { SegmentedControl, type SegmentedControlProps } from './radio-group.js';
8
8
  export { Filter, type FilterOption, type FilterProps } from './radio-group.js';
@@ -0,0 +1,2 @@
1
+ /** The settings blocks' header, published as `ScreenHeader` from `@bloxwap/hig/native/screen-header`. */
2
+ export { ScreenHeader as SettingHeader } from './screen-header.js';
@@ -0,0 +1,2 @@
1
+ /** The settings blocks' header, published as `ScreenHeader` from `@bloxwap/hig/native/screen-header`. */
2
+ export { ScreenHeader as SettingHeader } from './screen-header.js';
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ /** A secondary button under a setting, such as Open Settings. `feedback: false` keeps the provider's press feedback off this one button, for a host that plays its own cue for it; by default it plays like any `Button`. */
3
+ export interface SettingAction {
4
+ label: string;
5
+ onSelect: () => void;
6
+ disabled?: boolean;
7
+ feedback?: boolean;
8
+ }
9
+ export interface SettingSwitchProps {
10
+ label: string;
11
+ description?: string;
12
+ checked: boolean;
13
+ onCheckedChange: (checked: boolean) => void;
14
+ disabled?: boolean;
15
+ testID?: string;
16
+ /** Always on and not changeable: the switch shows on at full strength and is read as unavailable. Presses do nothing. */
17
+ locked?: boolean;
18
+ /** Host content after the label, such as a badge. It is drawn only: the switch is read by `label` (and `labelAccessoryLabel`), so put any meaning it carries there or in the description. */
19
+ labelAccessory?: React.ReactNode;
20
+ /** Host words for the `labelAccessory`, read after the label and a pause: `Feed, New`. Same prop on web. */
21
+ labelAccessoryLabel?: string;
22
+ }
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
+ 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. */
26
+ export declare function SettingCard({ children, joined, testID }: React.PropsWithChildren<{
27
+ joined?: boolean;
28
+ testID?: string;
29
+ }>): React.JSX.Element;
30
+ /** The shared header of a settings screen: Back on the leading edge, the title centred, a host control on the trailing edge. */
31
+ export { SettingHeader } from './setting-header.js';
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ import { useColors, useFills, useHIG } from './provider.js';
4
+ import { Text } from './surface.js';
5
+ import { SwitchRow } from './switch-row.js';
6
+ /** 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. */
7
+ export function SettingSwitch({ label, description, checked: requested, onCheckedChange, disabled, locked, labelAccessory, labelAccessoryLabel, testID }) {
8
+ const colors = useColors(), fills = useFills(), { direction } = useHIG();
9
+ const checked = locked ? true : requested;
10
+ const name = _jsx(Text, { style: { fontSize: 16, lineHeight: 24, color: colors.text }, children: label });
11
+ 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
+ }
14
+ /** The card a setting sits in. Inside a list the cards share one rounded container, so they drop their own radius. */
15
+ export function SettingCard({ children, joined, testID }) {
16
+ 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 });
18
+ }
19
+ /** The shared header of a settings screen: Back on the leading edge, the title centred, a host control on the trailing edge. */
20
+ export { SettingHeader } from './setting-header.js';
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import { View, type ScrollViewProps } from 'react-native';
3
+ /** One signal the viewer can turn on. */
4
+ export interface SignalsItem {
5
+ id: string;
6
+ label: string;
7
+ description?: string;
8
+ checked: boolean;
9
+ onCheckedChange: (checked: boolean) => void;
10
+ disabled?: boolean;
11
+ /** Always on and not changeable: shown on at full strength and read as unavailable. */
12
+ locked?: boolean;
13
+ /** Host content after the label, such as a badge. It is drawn only; the switch is read by `label`. */
14
+ labelAccessory?: React.ReactNode;
15
+ /** Host words for the `labelAccessory`, read after the label and a pause: `Feed, New`. */
16
+ labelAccessoryLabel?: string;
17
+ /** A neutral line under the switch, announced when it changes: Needs this device's permission. */
18
+ hint?: string;
19
+ /** A failure under the switch, in the negative role and announced. */
20
+ error?: string;
21
+ }
22
+ /** A family of signals under one heading: Trend, Swing. Every word is host text. */
23
+ export interface SignalsGroup {
24
+ id: string;
25
+ title: string;
26
+ /** Shows the verified mark after the title. */
27
+ verified?: boolean;
28
+ /** A small pill on the trailing edge of the heading: How it works. The host opens its own explanation. `ref` reaches the pill, so the host can move accessibility focus back to it when the explanation closes. */
29
+ help?: {
30
+ label: string;
31
+ onSelect: () => void;
32
+ ref?: React.Ref<View>;
33
+ };
34
+ items: readonly SignalsItem[];
35
+ }
36
+ export interface SignalsBlockProps {
37
+ /** Heading: Signals. */
38
+ title: string;
39
+ /** A muted line under the header that explains the screen. */
40
+ description?: string;
41
+ groups: readonly SignalsGroup[];
42
+ /** Words for the verified mark, read after the group title. */
43
+ verifiedLabel?: string;
44
+ /** Host artwork in place of the built-in verified mark, inside the heading's one accessible element. */
45
+ verifiedMark?: React.ReactNode;
46
+ /** The `verifiedMark` is a control: it stays in the accessibility tree, the heading then sits on the title text and the mark follows as its own element. */
47
+ verifiedMarkInteractive?: boolean;
48
+ /** Shows Back on the leading edge of the header. */
49
+ onBack?: () => void;
50
+ /** A control on the trailing edge of the header, usually an IconButton. */
51
+ headerAction?: React.ReactNode;
52
+ /** Keeps the header pinned while the groups scroll: the block becomes its own scroll view with the header as its sticky first child, transparent at rest and filled once content scrolls under it. Place it in a bounded container. */
53
+ stickyHeader?: boolean;
54
+ /** Fill behind the pinned header once content scrolls under it. Defaults to the background role; in a sheet pass the sheet's fill. */
55
+ stickyHeaderBackground?: string;
56
+ /** The scroll view used with `stickyHeader`, such as a sheet library's own. */
57
+ scrollComponent?: React.ComponentType<ScrollViewProps>;
58
+ testID?: string;
59
+ }
60
+ /** The signals the viewer receives, as a screen, in groups: each group has a heading with an optional verified mark and a small help pill, and its signals as switches with a line of explanation, sharing one rounded container. */
61
+ export declare function SignalsBlock({ title, description, groups, verifiedLabel, verifiedMark, verifiedMarkInteractive, onBack, headerAction, stickyHeader, stickyHeaderBackground, scrollComponent, testID }: SignalsBlockProps): React.JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ import { StickyHeaderLayout } from './sticky-header.js';
4
+ import { useColors, useHIG } from './provider.js';
5
+ import { Text } from './surface.js';
6
+ import { SwapCapsule } from './swap-parts.js';
7
+ import { SeverityIcon } from './icons.js';
8
+ import { SettingCard, SettingHeader, SettingSwitch } from './setting-switch.js';
9
+ /** The 32dp help pill keeps a 48dp touch target: 8dp beyond each edge, clear of the switches 8dp below the 44dp heading row. */
10
+ const helpSlop = { top: 8, bottom: 8, left: 8, right: 8 };
11
+ /** The signals the viewer receives, as a screen, in groups: each group has a heading with an optional verified mark and a small help pill, and its signals as switches with a line of explanation, sharing one rounded container. */
12
+ export function SignalsBlock({ title, description, groups, verifiedLabel, verifiedMark, verifiedMarkInteractive, onBack, headerAction, stickyHeader, stickyHeaderBackground, scrollComponent, testID }) {
13
+ const colors = useColors(), { direction } = useHIG();
14
+ const note = { fontSize: 14, lineHeight: 21 };
15
+ const split = (group) => !!group.verified && verifiedMark != null && !!verifiedMarkInteractive;
16
+ const heading = (group) => [group.title, group.verified && verifiedLabel ? verifiedLabel : null].filter(Boolean).join(', ');
17
+ const sections = groups.map(group => {
18
+ const id = `signals-${group.id}`;
19
+ return _jsxs(View, { testID: id, style: { gap: 8, marginTop: 16 }, children: [_jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 44, paddingStart: 4 }, children: [_jsxs(View, { accessible: !split(group), accessibilityRole: split(group) ? undefined : 'header', accessibilityLabel: split(group) ? undefined : heading(group), testID: `${id}-title`, style: { flexDirection: 'row', alignItems: 'center', gap: 6, flexShrink: 1 }, children: [_jsx(Text, { accessible: split(group), accessibilityRole: split(group) ? 'header' : undefined, accessibilityLabel: split(group) ? heading(group) : undefined, numberOfLines: 1, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '500', color: colors.muted }, children: group.title }), group.verified ? (verifiedMark != null ? _jsx(View, { testID: `${id}-verified`, children: verifiedMark }) : _jsx(View, { testID: `${id}-verified`, style: { transform: [{ scale: 0.8 }] }, children: _jsx(SeverityIcon, { kind: 'success', color: colors.warning }) })) : null] }), group.help ? _jsx(SwapCapsule, { ref: group.help.ref, testID: `${id}-help`, hitSlop: helpSlop, onPress: group.help.onSelect, children: _jsx(Text, { style: { fontSize: 14, lineHeight: 20, fontWeight: '500', color: colors.muted }, children: group.help.label }) }) : null] }), group.items.length > 0 ? _jsx(View, { testID: `${id}-items`, style: { gap: 2, borderRadius: 20, overflow: 'hidden' }, children: group.items.map(item => _jsxs(SettingCard, { joined: true, testID: `${id}-${item.id}`, children: [_jsx(SettingSwitch, { testID: `${id}-${item.id}-switch`, label: item.label, description: item.description, checked: item.checked, disabled: item.disabled, locked: item.locked, labelAccessory: item.labelAccessory, labelAccessoryLabel: item.labelAccessoryLabel, onCheckedChange: item.onCheckedChange }), item.hint || item.error ? _jsxs(View, { style: { gap: 4 }, children: [item.hint ? _jsx(Text, { testID: `${id}-${item.id}-hint`, accessibilityLiveRegion: 'polite', style: { ...note, color: colors.muted }, children: item.hint }) : null, item.error ? _jsx(Text, { testID: `${id}-${item.id}-error`, accessibilityRole: 'alert', accessibilityLiveRegion: 'polite', style: { ...note, color: colors.negative }, children: item.error }) : null] }) : null] }, item.id)) }) : null] }, group.id);
20
+ });
21
+ const header = _jsx(SettingHeader, { testID: 'signals', title: title, onBack: onBack, action: headerAction });
22
+ const body = _jsxs(_Fragment, { children: [description ? _jsx(Text, { testID: 'signals-description', style: { ...note, color: colors.muted, marginTop: 16, paddingHorizontal: 4 }, children: description }) : null, sections] });
23
+ if (stickyHeader)
24
+ return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: 'signals-sticky-header', header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: body });
25
+ return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [header, body] });
26
+ }
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import { type ScrollViewProps } from 'react-native';
3
+ import { type SettingAction } from './setting-switch.js';
4
+ export type { SettingAction } from './setting-switch.js';
5
+ import type { Choice } from './selection-types.js';
6
+ /** A volume as a few fixed steps. `value` and `options` are fractions: 0.25 reads 25%. */
7
+ export interface SoundVolume {
8
+ /** Names the steps and is drawn above them: Volume. */
9
+ label: string;
10
+ /** Defaults to 25%, 50%, 75% and 100%. */
11
+ options?: readonly number[];
12
+ value: number;
13
+ onValueChange: (value: number) => void;
14
+ }
15
+ /** One feedback channel: sound effects, the microphone, haptics, the flash. Every word is host text. */
16
+ export interface SoundSection {
17
+ id: string;
18
+ label: string;
19
+ description?: string;
20
+ checked: boolean;
21
+ onCheckedChange: (checked: boolean) => void;
22
+ disabled?: boolean;
23
+ /** The device in use, under the switch: iPhone Microphone. */
24
+ source?: string;
25
+ /** A choice between devices, as radios under the source: Automatic, iPhone Microphone, AirPods. Shown while the channel is on. */
26
+ choices?: SoundChoices;
27
+ /** A live input level from 0 to 1, drawn as a meter. `null` draws an empty meter. */
28
+ level?: number | null;
29
+ /** Names the meter for assistive technology, which then reads the level as a percentage. Without it the meter is decorative. */
30
+ levelLabel?: string;
31
+ volume?: SoundVolume;
32
+ /** What the volume does while the channel is off: `hidden` (the default) leaves it out, `disabled` keeps it in place and unavailable. */
33
+ volumeWhenOff?: 'hidden' | 'disabled';
34
+ /** A secondary action at the foot of the card, shown whether the channel is on or off: Open Settings. `feedback: false` keeps the provider's press feedback off it. */
35
+ action?: SettingAction;
36
+ }
37
+ /** A choice of device under the source, such as which microphone to use. `label` names the group and is drawn above it. */
38
+ export interface SoundChoices {
39
+ label: string;
40
+ options: readonly Choice[];
41
+ value: string;
42
+ onValueChange: (value: string) => void;
43
+ }
44
+ export interface SoundHapticsBlockProps {
45
+ /** Heading: Sound & Haptics. */
46
+ title: string;
47
+ /** A muted line under the header that explains the screen. */
48
+ description?: string;
49
+ /** One card each, in order. A section's source, choices and meter show only while it is on; its volume too unless `volumeWhenOff` is `disabled`. */
50
+ sections: readonly SoundSection[];
51
+ /** Shows Back on the leading edge of the header. */
52
+ onBack?: () => void;
53
+ /** A control on the trailing edge of the header, usually an IconButton. */
54
+ headerAction?: React.ReactNode;
55
+ /** Keeps the header pinned while the cards scroll: the block becomes its own scroll view with the header as its sticky first child, transparent at rest and filled once content scrolls under it. Place it in a bounded container. */
56
+ stickyHeader?: boolean;
57
+ /** Fill behind the pinned header once content scrolls under it. Defaults to the background role; in a sheet pass the sheet's fill. */
58
+ stickyHeaderBackground?: string;
59
+ /** The scroll view used with `stickyHeader`, such as a sheet library's own. */
60
+ scrollComponent?: React.ComponentType<ScrollViewProps>;
61
+ testID?: string;
62
+ }
63
+ /** The share of the meter filled, from 0 to 1. Unknown and out-of-range levels are clamped. */
64
+ export declare const soundLevel: (level: number | null | undefined) => number;
65
+ /** The settings for what the app plays and feels like, as a screen: each channel is a card with a switch, and a channel that is on can show the device it uses, a live input meter and its volume as fixed steps. */
66
+ export declare function SoundHapticsBlock({ title, description, sections, onBack, headerAction, stickyHeader, stickyHeaderBackground, scrollComponent, testID }: SoundHapticsBlockProps): React.JSX.Element;
@@ -0,0 +1,32 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ import { formatNumber } from '@bloxwap/hig/contracts';
4
+ import { useColors, useFills, useHIG, useNumberLocale } from './provider.js';
5
+ import { Text } from './surface.js';
6
+ import { Button } from './button.js';
7
+ import { SettingCard, SettingHeader, SettingSwitch } from './setting-switch.js';
8
+ import { StickyHeaderLayout } from './sticky-header.js';
9
+ import { RadioGroup } from './radio-group.js';
10
+ const steps = [0.25, 0.5, 0.75, 1], percent = { style: 'percent', maximumFractionDigits: 0 };
11
+ const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
12
+ /** The share of the meter filled, from 0 to 1. Unknown and out-of-range levels are clamped. */
13
+ export const soundLevel = (level) => level == null || !Number.isFinite(level) ? 0 : Math.min(1, Math.max(0, level));
14
+ /** The settings for what the app plays and feels like, as a screen: each channel is a card with a switch, and a channel that is on can show the device it uses, a live input meter and its volume as fixed steps. */
15
+ export function SoundHapticsBlock({ title, description, sections, onBack, headerAction, stickyHeader, stickyHeaderBackground, scrollComponent, testID }) {
16
+ const colors = useColors(), fills = useFills(), { direction } = useHIG(), locale = useNumberLocale();
17
+ const caption = { fontSize: 14, lineHeight: 21, color: colors.muted };
18
+ const cards = sections.map(section => {
19
+ const { source, choices, level, levelLabel, volume, action } = section, on = section.checked, id = `sound-${section.id}`;
20
+ const showVolume = !!volume && (on || section.volumeWhenOff === 'disabled');
21
+ const open = (on && (!!source || !!choices || level !== undefined)) || showVolume || !!action;
22
+ const share = soundLevel(level);
23
+ const fill = _jsx(View, { testID: `${id}-level`, style: { width: `${share * 100}%`, borderRadius: 2, backgroundColor: colors.action } }), track = { direction, flexDirection: 'row', height: 4, borderRadius: 2, backgroundColor: fills.raised, overflow: 'hidden' };
24
+ return _jsxs(SettingCard, { testID: id, children: [_jsx(SettingSwitch, { testID: `${id}-switch`, label: section.label, description: section.description, checked: section.checked, disabled: section.disabled, onCheckedChange: section.onCheckedChange }), open ? _jsxs(View, { testID: `${id}-body`, style: { gap: 8 }, children: [on && source ? _jsx(Text, { testID: `${id}-source`, style: caption, children: source }) : null, on && choices ? _jsx(View, { testID: `${id}-choices`, children: _jsx(RadioGroup, { label: choices.label, options: choices.options, value: choices.value, disabled: section.disabled, onValueChange: choices.onValueChange }) }) : null, on && level !== undefined ? (levelLabel ? _jsx(View, { testID: `${id}-meter`, accessible: true, accessibilityRole: 'progressbar', accessibilityLabel: levelLabel, accessibilityValue: { min: 0, max: 100, now: Math.round(share * 100), text: formatNumber(share, locale, percent) }, style: track, children: fill })
25
+ : _jsx(View, { ...hidden, testID: `${id}-meter`, style: track, children: fill })) : null, showVolume && volume ? _jsxs(View, { testID: `${id}-volume`, accessibilityRole: 'radiogroup', accessibilityLabel: volume.label, style: { gap: 8 }, children: [_jsx(Text, { ...hidden, style: caption, children: volume.label }), _jsx(View, { style: { direction, flexDirection: 'row', gap: 8 }, children: (volume.options ?? steps).map(option => _jsx(Button, { testID: `${id}-volume-${option}`, intent: option === volume.value ? 'primary' : 'secondary', accessibilityState: { selected: option === volume.value }, disabled: on ? section.disabled : true, onPress: () => volume.onValueChange(option), style: { flex: 1, alignSelf: 'auto', paddingHorizontal: 8 }, children: formatNumber(option, locale, percent) }, option)) })] }) : null, action ? _jsx(View, { style: { marginTop: on && (source || choices || level !== undefined) || showVolume ? 8 : 0 }, children: _jsx(Button, { testID: `${id}-action`, intent: 'secondary', fullWidth: true, disabled: action.disabled, suppressFeedback: action.feedback === false, onPress: action.onSelect, children: action.label }) }) : null] }) : null] }, section.id);
26
+ });
27
+ const header = _jsx(SettingHeader, { testID: 'sound', title: title, onBack: onBack, action: headerAction });
28
+ const body = _jsxs(_Fragment, { children: [description ? _jsx(Text, { testID: 'sound-description', style: { ...caption, marginTop: 16, paddingHorizontal: 4 }, children: description }) : null, sections.length > 0 ? _jsx(View, { testID: 'sound-sections', style: { gap: 8, marginTop: 16 }, children: cards }) : null] });
29
+ if (stickyHeader)
30
+ return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: 'sound-sticky-header', header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: body });
31
+ return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [header, body] });
32
+ }