@bloxwap/hig 0.6.0 → 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 (167) hide show
  1. package/chart/README.md +1 -1
  2. package/contracts/README.md +1 -1
  3. package/contracts/dist/index.d.ts +16 -0
  4. package/contracts/dist/index.js +22 -0
  5. package/contracts/dist/messages.d.ts +6 -0
  6. package/contracts/dist/messages.js +3 -1
  7. package/feedback/README.md +1 -1
  8. package/native/README.md +1 -1
  9. package/native/dist/account-block.d.ts +53 -7
  10. package/native/dist/account-block.js +42 -9
  11. package/native/dist/animated-number-model.d.ts +7 -1
  12. package/native/dist/animated-number-model.js +50 -1
  13. package/native/dist/animated-number.d.ts +3 -1
  14. package/native/dist/animated-number.js +8 -5
  15. package/native/dist/asset-balance-row.d.ts +17 -1
  16. package/native/dist/asset-balance-row.js +13 -8
  17. package/native/dist/bar-mark.d.ts +14 -2
  18. package/native/dist/bar-mark.js +19 -5
  19. package/native/dist/bar-pnl.js +5 -4
  20. package/native/dist/blocks.d.ts +8 -14
  21. package/native/dist/blocks.js +5 -6
  22. package/native/dist/button.js +3 -1
  23. package/native/dist/data.d.ts +1 -1
  24. package/native/dist/data.js +6 -4
  25. package/native/dist/field.d.ts +14 -4
  26. package/native/dist/field.js +33 -7
  27. package/native/dist/figure.d.ts +23 -0
  28. package/native/dist/figure.js +10 -0
  29. package/native/dist/language-block.d.ts +5 -1
  30. package/native/dist/language-block.js +3 -3
  31. package/native/dist/list-group.d.ts +42 -8
  32. package/native/dist/list-group.js +71 -13
  33. package/native/dist/manage-position-block.d.ts +28 -2
  34. package/native/dist/manage-position-block.js +36 -11
  35. package/native/dist/market-row.d.ts +46 -0
  36. package/native/dist/market-row.js +30 -0
  37. package/native/dist/notifications-block.d.ts +30 -2
  38. package/native/dist/notifications-block.js +16 -8
  39. package/native/dist/pickers.d.ts +24 -2
  40. package/native/dist/pickers.js +16 -8
  41. package/native/dist/position-block.d.ts +66 -10
  42. package/native/dist/position-block.js +45 -11
  43. package/native/dist/profile-block.d.ts +29 -5
  44. package/native/dist/profile-block.js +25 -5
  45. package/native/dist/provider.d.ts +9 -3
  46. package/native/dist/provider.js +7 -3
  47. package/native/dist/radio-group.d.ts +9 -3
  48. package/native/dist/radio-group.js +4 -5
  49. package/native/dist/recipes.d.ts +6 -0
  50. package/native/dist/recipes.js +6 -0
  51. package/native/dist/reward-block.d.ts +45 -6
  52. package/native/dist/reward-block.js +30 -12
  53. package/native/dist/screen-header.d.ts +49 -0
  54. package/native/dist/screen-header.js +29 -0
  55. package/native/dist/selection.d.ts +2 -2
  56. package/native/dist/setting-header.d.ts +2 -8
  57. package/native/dist/setting-header.js +2 -11
  58. package/native/dist/setting-switch.d.ts +14 -1
  59. package/native/dist/setting-switch.js +5 -2
  60. package/native/dist/signals-block.d.ts +26 -2
  61. package/native/dist/signals-block.js +14 -4
  62. package/native/dist/sound-haptics-block.d.ts +29 -2
  63. package/native/dist/sound-haptics-block.js +18 -7
  64. package/native/dist/status.d.ts +6 -5
  65. package/native/dist/status.js +5 -5
  66. package/native/dist/sticky-header.d.ts +28 -0
  67. package/native/dist/sticky-header.js +21 -0
  68. package/native/dist/surface.d.ts +3 -1
  69. package/native/dist/surface.js +2 -1
  70. package/native/dist/swap-panel-block.d.ts +2 -1
  71. package/native/dist/swap-panel-block.js +9 -6
  72. package/native/dist/swap-parts.d.ts +5 -3
  73. package/native/dist/swap-parts.js +2 -2
  74. package/native/dist/swap-shared.d.ts +6 -0
  75. package/native/dist/swap-views.js +5 -3
  76. package/native/dist/switch-row.d.ts +3 -2
  77. package/native/dist/switch-row.js +5 -3
  78. package/native/dist/switch.d.ts +4 -2
  79. package/native/dist/switch.js +3 -3
  80. package/native/dist/target-block.d.ts +33 -6
  81. package/native/dist/target-block.js +19 -6
  82. package/native/dist/token-action-block.d.ts +17 -9
  83. package/native/dist/token-action-block.js +14 -6
  84. package/native/dist/trade-history-detail-block.d.ts +26 -1
  85. package/native/dist/trade-history-detail-block.js +17 -9
  86. package/native/dist/trade-history-list-block.d.ts +71 -5
  87. package/native/dist/trade-history-list-block.js +50 -15
  88. package/native/dist/wallet-address-core.d.ts +25 -0
  89. package/native/dist/wallet-address-core.js +31 -0
  90. package/native/dist/wallet-address.d.ts +6 -10
  91. package/native/dist/wallet-address.js +16 -20
  92. package/native-fonts/README.md +1 -1
  93. package/og-fonts/README.md +1 -1
  94. package/package.json +21 -1
  95. package/react/README.md +1 -1
  96. package/react/dist/animated-number-model.d.ts +6 -0
  97. package/react/dist/animated-number-model.js +33 -0
  98. package/react/dist/animated-number.d.ts +5 -1
  99. package/react/dist/animated-number.js +12 -8
  100. package/react/dist/asset-balance-row.d.ts +17 -1
  101. package/react/dist/asset-balance-row.js +11 -3
  102. package/react/dist/bar-mark.d.ts +5 -2
  103. package/react/dist/bar-mark.js +5 -3
  104. package/react/dist/blocks/account-block.d.ts +53 -7
  105. package/react/dist/blocks/account-block.js +45 -10
  106. package/react/dist/blocks/language-block.d.ts +5 -1
  107. package/react/dist/blocks/language-block.js +6 -5
  108. package/react/dist/blocks/manage-position-block.d.ts +28 -2
  109. package/react/dist/blocks/manage-position-block.js +23 -4
  110. package/react/dist/blocks/market-row.d.ts +20 -9
  111. package/react/dist/blocks/market-row.js +12 -4
  112. package/react/dist/blocks/notifications-block.d.ts +25 -2
  113. package/react/dist/blocks/notifications-block.js +11 -2
  114. package/react/dist/blocks/pickers.d.ts +21 -1
  115. package/react/dist/blocks/pickers.js +30 -10
  116. package/react/dist/blocks/position-block.d.ts +34 -11
  117. package/react/dist/blocks/position-block.js +16 -5
  118. package/react/dist/blocks/profile-block.d.ts +29 -6
  119. package/react/dist/blocks/profile-block.js +31 -5
  120. package/react/dist/blocks/reward-block.d.ts +53 -14
  121. package/react/dist/blocks/reward-block.js +20 -10
  122. package/react/dist/blocks/screen-header.d.ts +26 -2
  123. package/react/dist/blocks/screen-header.js +13 -5
  124. package/react/dist/blocks/setting-switch.d.ts +14 -1
  125. package/react/dist/blocks/setting-switch.js +8 -4
  126. package/react/dist/blocks/signals-block.d.ts +21 -2
  127. package/react/dist/blocks/signals-block.js +5 -5
  128. package/react/dist/blocks/sound-haptics-block.d.ts +25 -3
  129. package/react/dist/blocks/sound-haptics-block.js +11 -7
  130. package/react/dist/blocks/sticky-header.d.ts +9 -0
  131. package/react/dist/blocks/sticky-header.js +43 -0
  132. package/react/dist/blocks/swap/amount-card.js +2 -1
  133. package/react/dist/blocks/swap/settings.js +2 -2
  134. package/react/dist/blocks/swap/shared.d.ts +7 -1
  135. package/react/dist/blocks/swap/shared.js +6 -4
  136. package/react/dist/blocks/swap-panel-block.d.ts +2 -0
  137. package/react/dist/blocks/swap-panel-block.js +6 -6
  138. package/react/dist/blocks/target-block.d.ts +28 -6
  139. package/react/dist/blocks/target-block.js +17 -9
  140. package/react/dist/blocks/token-action-block.d.ts +17 -8
  141. package/react/dist/blocks/token-action-block.js +9 -6
  142. package/react/dist/blocks/trade-history-detail-block.d.ts +21 -1
  143. package/react/dist/blocks/trade-history-detail-block.js +5 -4
  144. package/react/dist/blocks/trade-history-list-block.d.ts +29 -5
  145. package/react/dist/blocks/trade-history-list-block.js +15 -8
  146. package/react/dist/blocks.d.ts +8 -8
  147. package/react/dist/blocks.js +2 -2
  148. package/react/dist/button.js +6 -4
  149. package/react/dist/data.js +3 -3
  150. package/react/dist/field.d.ts +14 -4
  151. package/react/dist/field.js +19 -6
  152. package/react/dist/figure.d.ts +23 -0
  153. package/react/dist/figure.js +12 -0
  154. package/react/dist/list-group.d.ts +41 -8
  155. package/react/dist/list-group.js +44 -12
  156. package/react/dist/provider.d.ts +40 -3
  157. package/react/dist/provider.js +63 -6
  158. package/react/dist/selection.d.ts +8 -2
  159. package/react/dist/selection.js +11 -6
  160. package/react/dist/styles.css +164 -9
  161. package/react/dist/surface.d.ts +5 -1
  162. package/react/dist/surface.js +1 -1
  163. package/react/dist/wallet-address-core.d.ts +23 -0
  164. package/react/dist/wallet-address-core.js +24 -0
  165. package/react/dist/wallet-address.d.ts +6 -12
  166. package/react/dist/wallet-address.js +5 -16
  167. package/tokens/README.md +1 -1
package/chart/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @bloxwap/hig/chart
2
2
 
3
- Version 0.6.0, an entry of `@bloxwap/hig`. The HIG adapter for [`@bloxwap/chart`](https://github.com/bloxwap/chart): `PriceChart` (a
3
+ Version 0.7.0, an entry of `@bloxwap/hig`. The HIG adapter for [`@bloxwap/chart`](https://github.com/bloxwap/chart): `PriceChart` (a
4
4
  `<figure>` with a required text `summary`, lazy-loading `@bloxwap/chart/react` inside `Suspense`) and
5
5
  `chartTheme` (HIG token colors in sRGB for the canvas). Web only; React Native uses labeled readouts and lists
6
6
  from `@bloxwap/hig/native/data`.
@@ -1,3 +1,3 @@
1
1
  # @bloxwap/hig/contracts
2
2
 
3
- Version 0.6.0, an entry of `@bloxwap/hig`. See the HIG architecture and platform limitations before adoption.
3
+ Version 0.7.0, an entry of `@bloxwap/hig`. See the HIG architecture and platform limitations before adoption.
@@ -19,6 +19,22 @@ export type HostLocale = string | {
19
19
  * only in apps that lay out right to left: it reports the locale's direction, not whether the host allows RTL (#86).
20
20
  */
21
21
  export declare function localeDirection(locale: HostLocale | null | undefined): Direction | undefined;
22
+ /** How money reads across a provider: the currency sign and digit grouping a host's own figures use, such as `narrowSymbol` so French reads `12,50 $` rather than `12,50 $US`. */
23
+ export interface NumberFormatPresentation {
24
+ /** How the currency is named. Intl's default is `symbol`. */
25
+ currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name';
26
+ /** Digit grouping. `'always'` groups four-digit amounts in locales that otherwise leave them ungrouped, such as Spanish. */
27
+ useGrouping?: boolean | 'always' | 'auto' | 'min2';
28
+ /** The locale numbers are formatted in, when it differs from the provider's interface `locale`: `'en-US'` keeps Korean or Chinese figures in US separators. It changes every number HIG formats (separators, digits and currency placement), not only money. Omitted, numbers follow the provider's `locale`. */
29
+ locale?: string;
30
+ }
31
+ /** The locale HIG formats numbers in: the presentation's `locale` when it names one, otherwise the interface locale. */
32
+ export declare function numberLocale(locale: string, presentation?: NumberFormatPresentation): string;
33
+ /**
34
+ * Merges a provider's money presentation under the options of one currency format. Only `style: 'currency'` options change, and any
35
+ * field the options set themselves wins. Without a presentation, or for any other style, the same options object is returned.
36
+ */
37
+ export declare function presentNumberFormat<T extends Intl.NumberFormatOptions | undefined>(options: T, presentation?: NumberFormatPresentation): T;
22
38
  /** Display only. Keep raw decimal strings in transaction logic. */
23
39
  export declare function formatNumber(value: number | null | undefined, locale?: string, options?: Intl.NumberFormatOptions): string;
24
40
  /** Leverage multiplier display (`10×`). Never percent-styled; the `×` suffix is untranslated. Unknown → `—`. */
@@ -23,6 +23,28 @@ export function localeDirection(locale) {
23
23
  const script = (singleton < 0 ? rest : rest.slice(0, singleton)).find(subtag => /^[a-z]{4}$/.test(subtag));
24
24
  return (script ? rtlScripts.has(script) : rtlLanguages.has(language)) ? 'rtl' : 'ltr';
25
25
  }
26
+ /** The locale HIG formats numbers in: the presentation's `locale` when it names one, otherwise the interface locale. */
27
+ export function numberLocale(locale, presentation) {
28
+ const own = presentation?.locale;
29
+ return typeof own === 'string' && own.trim() !== '' ? own : locale;
30
+ }
31
+ /**
32
+ * Merges a provider's money presentation under the options of one currency format. Only `style: 'currency'` options change, and any
33
+ * field the options set themselves wins. Without a presentation, or for any other style, the same options object is returned.
34
+ */
35
+ export function presentNumberFormat(options, presentation) {
36
+ if (!presentation || options?.style !== 'currency')
37
+ return options;
38
+ const merged = {};
39
+ if (presentation.currencyDisplay !== undefined)
40
+ merged.currencyDisplay = presentation.currencyDisplay;
41
+ if (presentation.useGrouping !== undefined)
42
+ merged.useGrouping = presentation.useGrouping;
43
+ for (const [key, value] of Object.entries(options))
44
+ if (value !== undefined)
45
+ merged[key] = value;
46
+ return merged;
47
+ }
26
48
  /** Display only. Keep raw decimal strings in transaction logic. */
27
49
  export function formatNumber(value, locale = 'en-US', options = {}) {
28
50
  return value == null || !Number.isFinite(value) ? '—' : new Intl.NumberFormat(locale, options).format(value);
@@ -206,12 +206,16 @@ export interface HIGMessages {
206
206
  showAddress: string;
207
207
  /** ProfileBlock: accessible name of the control that edits the profile name. */
208
208
  editName: string;
209
+ /** ProfileBlock: accessible name of the avatar button when the host gives neither `avatarLabel` nor `name`. */
210
+ changeProfilePicture: string;
209
211
  /** TokenActionBlock: built-in label of the `receive` action. */
210
212
  receive: string;
211
213
  /** TokenActionBlock: built-in label of the `stake` action. */
212
214
  stake: string;
213
215
  /** TokenActionBlock: built-in label of the `unstake` action. */
214
216
  unstake: string;
217
+ /** SearchInput: accessible name of the clear button when the host gives no `clearLabel`. */
218
+ clearSearch: string;
215
219
  }
216
220
  export declare const close = "Close";
217
221
  export declare const cancel = "Cancel";
@@ -310,11 +314,13 @@ export declare const deposit = "Deposit";
310
314
  export declare const accountBalance = "Total balance";
311
315
  export declare const showAddress = "Show account address";
312
316
  export declare const editName = "Edit name";
317
+ export declare const changeProfilePicture = "Change profile picture";
313
318
  export declare const language = "Language";
314
319
  export declare const searchLanguages = "Search languages";
315
320
  export declare const receive = "Receive";
316
321
  export declare const stake = "Stake";
317
322
  export declare const unstake = "Unstake";
323
+ export declare const clearSearch = "Clear search";
318
324
  /** The complete English catalog. */
319
325
  export declare const defaultMessages: Readonly<HIGMessages>;
320
326
  /** Every message key, in documentation order. */
@@ -96,13 +96,15 @@ export const deposit = 'Deposit';
96
96
  export const accountBalance = 'Total balance';
97
97
  export const showAddress = 'Show account address';
98
98
  export const editName = 'Edit name';
99
+ export const changeProfilePicture = 'Change profile picture';
99
100
  export const language = 'Language';
100
101
  export const searchLanguages = 'Search languages';
101
102
  export const receive = 'Receive';
102
103
  export const stake = 'Stake';
103
104
  export const unstake = 'Unstake';
105
+ export const clearSearch = 'Clear search';
104
106
  /** The complete English catalog. */
105
- export const defaultMessages = { close, cancel, dismiss, dismissNotice, busy, notifications, loading, loadingContent, loadingItems, loadingChart, noItems, noRows, retry, loadMore, stale, required, breadcrumb, pagination, previous, next, pageOf, search, searching, noResults, resultCount, back, menuDescription, choose, chooseOne, inProgress, progressValue, copied, copyFailed, copyInstallCommand, reviewAssetOrder, amountInAsset, availableAmount, reviewOrder, confirmOrder, confirmOrderDescription, orderUnavailable, statusOnline, statusOffline, statusStale, increase, decrease, swapFrom, swapTo, swapSelectToken, swapAmount, swapSwitchDenomination, swapFlip, swapActionSend, swapActionSwap, swapActionBridge, swapChooseToken, swapChooseDestination, swapEnterAmount, swapInsufficient, swapSendFromWallet, swapReset, swapSettings, swapMax, swapTest, swapSlippage, swapSlippageTitle, swapSlippageCustom, swapFee, swapFees, swapFeeTotal, swapDenomination, swapDollars, swapUnits, swapSearchTokens, swapChains, swapAllChains, swapHot, swapAllTokens, swapNoTokens, swapSelected, swapConnectWallet, swapDisconnect, swapGenerateAddress, swapRecipient, swapScan, copyAddress, addressCopied, tapToCopy, qrCode, swapControlKey, swapKeypad, swapDelete, account, deposit, accountBalance, showAddress, editName, language, searchLanguages, receive, stake, unstake };
107
+ export const defaultMessages = { close, cancel, dismiss, dismissNotice, busy, notifications, loading, loadingContent, loadingItems, loadingChart, noItems, noRows, retry, loadMore, stale, required, breadcrumb, pagination, previous, next, pageOf, search, searching, noResults, resultCount, back, menuDescription, choose, chooseOne, inProgress, progressValue, copied, copyFailed, copyInstallCommand, reviewAssetOrder, amountInAsset, availableAmount, reviewOrder, confirmOrder, confirmOrderDescription, orderUnavailable, statusOnline, statusOffline, statusStale, increase, decrease, swapFrom, swapTo, swapSelectToken, swapAmount, swapSwitchDenomination, swapFlip, swapActionSend, swapActionSwap, swapActionBridge, swapChooseToken, swapChooseDestination, swapEnterAmount, swapInsufficient, swapSendFromWallet, swapReset, swapSettings, swapMax, swapTest, swapSlippage, swapSlippageTitle, swapSlippageCustom, swapFee, swapFees, swapFeeTotal, swapDenomination, swapDollars, swapUnits, swapSearchTokens, swapChains, swapAllChains, swapHot, swapAllTokens, swapNoTokens, swapSelected, swapConnectWallet, swapDisconnect, swapGenerateAddress, swapRecipient, swapScan, copyAddress, addressCopied, tapToCopy, qrCode, swapControlKey, swapKeypad, swapDelete, account, deposit, accountBalance, showAddress, editName, changeProfilePicture, language, searchLanguages, receive, stake, unstake, clearSearch };
106
108
  /** Every message key, in documentation order. */
107
109
  export const messageKeys = /* @__PURE__ */ Object.keys(defaultMessages);
108
110
  /**
@@ -1,6 +1,6 @@
1
1
  # @bloxwap/hig/feedback
2
2
 
3
- Version 0.6.0, an entry of `@bloxwap/hig`. Root contract imports no React, DOM, RN, audio or device API. Use independent web/native entries and opt in to each channel. Successful API invocation never certifies physical output. See docs/feedback for timing, storage, capability and device verification.
3
+ Version 0.7.0, an entry of `@bloxwap/hig`. Root contract imports no React, DOM, RN, audio or device API. Use independent web/native entries and opt in to each channel. Successful API invocation never certifies physical output. See docs/feedback for timing, storage, capability and device verification.
4
4
 
5
5
  `createWebSoundAdapter` passes a per-adapter abort signal to SFX. The signal-aware engine cancels that root's active voices while other roots and host-owned playback continue. The shared default engine remains reference-counted.
6
6
 
package/native/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @bloxwap/hig/native
2
2
 
3
- Version 0.6.0, an entry of `@bloxwap/hig`. Import individual entries; see docs/components for platform and accessibility contracts.
3
+ Version 0.7.0, an entry of `@bloxwap/hig`. Import individual entries; see docs/components for platform and accessibility contracts.
4
4
 
5
5
  Set a brand accent with `<HIGProvider primaryColor='#ff0000'>` from
6
6
  `@bloxwap/hig/native/provider`. It accepts opaque sRGB hex (`#RGB` or `#RRGGBB`),
@@ -13,6 +13,38 @@ export interface AccountAsset {
13
13
  price?: number | null;
14
14
  /** USD value; defaults to balance × price. */
15
15
  value?: number | null;
16
+ /** Set false to draw no units line, for a holding whose units are the same figure as its value. */
17
+ units?: boolean;
18
+ /** Set false to draw this row plain even when the block has `onAssetSelect`. */
19
+ selectable?: boolean;
20
+ /** Format of the units figure; default `{maximumFractionDigits:6}`. */
21
+ unitsOptions?: Intl.NumberFormatOptions;
22
+ /** Host text after the units figure, such as ` PAPER`. */
23
+ unitsSuffix?: string;
24
+ /** Short muted host text under the figures, such as the ledger the holding sits in (Perp, Spot, Staked). */
25
+ tag?: string;
26
+ /** When the value is unknown but the balance is known: `units` (the default) headlines the units; `dash` shows the unknown dash over the units, for a value that is still loading. */
27
+ unknownValue?: 'units' | 'dash';
28
+ }
29
+ /** Row order after the pinned asset: `value` (largest first, the default) or `given` (the order the host passed). */
30
+ export type AccountOrder = 'value' | 'given';
31
+ /** How `accountRows` picks and orders: `order` after the pinned asset, and `pinnedId`, an asset id pinned in place of the symbol match. */
32
+ export interface AccountRowsOptions {
33
+ order?: AccountOrder;
34
+ pinnedId?: string;
35
+ }
36
+ /** A titled group of holdings with its own total, such as one ledger of the account. */
37
+ export interface AccountSection {
38
+ id: string;
39
+ /** Heading over the group. */
40
+ title: string;
41
+ /** The group's total in dollars, on the trailing edge of its heading; defaults to the sum of its asset values. `null` shows it as unknown. */
42
+ total?: number | null;
43
+ assets: readonly AccountAsset[];
44
+ /** Row order in this group; defaults to the block's `order`. */
45
+ order?: AccountOrder;
46
+ /** Id of the asset that leads this group; defaults to the block's `pinnedId`, then the `pinnedSymbol` match. */
47
+ pinnedId?: string;
16
48
  }
17
49
  export interface AccountBlockProps {
18
50
  /** Defaults to the localized "Account". */
@@ -23,24 +55,38 @@ export interface AccountBlockProps {
23
55
  onShowAddress?: () => void;
24
56
  /** A control on the trailing edge of the header, usually an IconButton. Replaces the QR button. */
25
57
  headerAction?: React.ReactNode;
26
- /** Total in dollars; defaults to the sum of the asset values. `null` shows it as unknown. */
58
+ /** Total in dollars; defaults to the sum of the asset values (with `sections`, the sum of the totals of the sections that are drawn, which is unknown when any of those totals is). `null` shows it as unknown. */
27
59
  balance?: number | null;
28
- assets: readonly AccountAsset[];
60
+ /** Every holding as one list: the pinned asset, then the rest by value. Ignored when `sections` is set. */
61
+ assets?: readonly AccountAsset[];
62
+ /** Titled groups, each with its own total, drawn in the order given in place of the flat `assets` list. */
63
+ sections?: readonly AccountSection[];
29
64
  /** Symbol of the asset pinned first; default 'USDC'. */
30
65
  pinnedSymbol?: string;
66
+ /** Id of the asset pinned first, in place of the `pinnedSymbol` match, for a holding whose symbol is not unique. */
67
+ pinnedId?: string;
68
+ /** Order of the rows after the pinned one: `value` (largest first, the default) or `given` (the order passed). */
69
+ order?: AccountOrder;
31
70
  /** Shows the deposit action beside the total. */
32
71
  onDeposit?: () => void;
33
72
  depositLabel?: string;
34
- /** Makes each row a button. */
35
- onAssetSelect?: (asset: AccountAsset) => void;
73
+ /** Makes each row a button that reports its asset, and with `sections` the section it is in. */
74
+ onAssetSelect?: (asset: AccountAsset, section?: AccountSection) => void;
36
75
  testID?: string;
37
76
  }
38
77
  /** An asset's dollar value: its own `value`, else balance × price, else unknown. */
39
78
  export declare const assetValue: (asset: AccountAsset) => number | null;
40
- /** The pinned asset (a zero placeholder when the account does not hold it) and the rest by dollar value, largest first, unknown values last, ties by name. */
41
- export declare function accountRows(assets: readonly AccountAsset[], pinnedSymbol?: string): {
79
+ /** The pinned asset (the one with `options.pinnedId`, else the first with `pinnedSymbol`, else a zero placeholder) and the rest by dollar value, largest first, unknown values last, ties by name, or with `options.order` `given` in the order passed. */
80
+ export declare function accountRows(assets: readonly AccountAsset[], pinnedSymbol?: string, options?: AccountRowsOptions): {
42
81
  pinned: AccountAsset;
43
82
  rest: AccountAsset[];
44
83
  };
84
+ /** A section's total: its own `total`, or the sum of its asset values. */
85
+ export declare const accountSectionTotal: (section: AccountSection) => number | null;
86
+ /** A section's rows in display order: the pinned asset first when the section holds it (no placeholder), then the rest by value as in `accountRows`. */
87
+ export declare function accountSectionRows(assets: readonly AccountAsset[], pinnedSymbol?: string, options?: AccountRowsOptions): {
88
+ pinned: AccountAsset | null;
89
+ rest: AccountAsset[];
90
+ };
45
91
  /** The account as one screen: a header, the total with the deposit action, the pinned asset, then every other holding by value. */
46
- export declare function AccountBlock({ title, onBack, onShowAddress, headerAction, balance, assets, pinnedSymbol, onDeposit, depositLabel, onAssetSelect, testID }: AccountBlockProps): React.JSX.Element;
92
+ export declare function AccountBlock({ title, onBack, onShowAddress, headerAction, balance, assets, sections, pinnedSymbol, pinnedId, order, onDeposit, depositLabel, onAssetSelect, testID }: AccountBlockProps): React.JSX.Element;
@@ -11,18 +11,51 @@ const usdc = 'USDC', usdCoin = 'USD Coin';
11
11
  const usd = { style: 'currency', currency: 'USD' };
12
12
  /** An asset's dollar value: its own `value`, else balance × price, else unknown. */
13
13
  export const assetValue = (asset) => asset.value !== undefined ? asset.value : asset.balance != null && asset.price != null ? asset.balance * asset.price : null;
14
- /** The pinned asset (a zero placeholder when the account does not hold it) and the rest by dollar value, largest first, unknown values last, ties by name. */
15
- export function accountRows(assets, pinnedSymbol = usdc) {
16
- const wanted = pinnedSymbol.toLowerCase(), found = assets.find(asset => asset.symbol.toLowerCase() === wanted);
14
+ /** The pinned asset (the one with `options.pinnedId`, else the first with `pinnedSymbol`, else a zero placeholder) and the rest by dollar value, largest first, unknown values last, ties by name, or with `options.order` `given` in the order passed. */
15
+ export function accountRows(assets, pinnedSymbol = usdc, options = {}) {
16
+ const wanted = pinnedSymbol.toLowerCase();
17
+ const found = (options.pinnedId === undefined ? undefined : assets.find(asset => asset.id === options.pinnedId)) ?? assets.find(asset => asset.symbol.toLowerCase() === wanted);
17
18
  const pinned = found ?? { id: pinnedSymbol, name: pinnedSymbol === usdc ? usdCoin : pinnedSymbol, symbol: pinnedSymbol, balance: 0, value: 0 };
18
- const rest = assets.filter(asset => asset !== found).sort((a, b) => { const x = assetValue(a), y = assetValue(b); return x === y ? a.name.localeCompare(b.name) : x === null ? 1 : y === null ? -1 : y - x || a.name.localeCompare(b.name); });
19
+ const others = assets.filter(asset => asset !== found);
20
+ const rest = options.order === 'given' ? others : others.sort((a, b) => { const x = assetValue(a), y = assetValue(b); return x === y ? a.name.localeCompare(b.name) : x === null ? 1 : y === null ? -1 : y - x || a.name.localeCompare(b.name); });
19
21
  return { pinned, rest };
20
22
  }
23
+ const sum = (assets) => assets.reduce((total, asset) => total + (assetValue(asset) ?? 0), 0);
24
+ /** A section's total: its own `total`, or the sum of its asset values. */
25
+ export const accountSectionTotal = (section) => section.total !== undefined ? section.total : sum(section.assets);
26
+ /** The block total for `sections`: the sum of the section totals, or unknown (`null`) when any of them is unknown. Pass only the sections that are drawn. */
27
+ const accountSectionsTotal = (sections) => { let all = 0; for (const section of sections) {
28
+ const total = accountSectionTotal(section);
29
+ if (total === null)
30
+ return null;
31
+ all += total;
32
+ } return all; };
33
+ /** A section's rows in display order: the pinned asset first when the section holds it (no placeholder), then the rest by value as in `accountRows`. */
34
+ export function accountSectionRows(assets, pinnedSymbol = usdc, options = {}) {
35
+ const { pinned, rest } = accountRows(assets, pinnedSymbol, options);
36
+ return { pinned: assets.includes(pinned) ? pinned : null, rest };
37
+ }
21
38
  /** The account as one screen: a header, the total with the deposit action, the pinned asset, then every other holding by value. */
22
- export function AccountBlock({ title, onBack, onShowAddress, headerAction, balance, assets, pinnedSymbol = usdc, onDeposit, depositLabel, onAssetSelect, testID }) {
39
+ export function AccountBlock({ title, onBack, onShowAddress, headerAction, balance, assets = [], sections, pinnedSymbol = usdc, pinnedId, order, onDeposit, depositLabel, onAssetSelect, testID }) {
23
40
  const colors = useColors(), t = useMessages(), { direction } = useHIG();
24
- const { pinned, rest } = accountRows(assets, pinnedSymbol);
25
- const total = balance !== undefined ? balance : assets.reduce((sum, asset) => sum + (assetValue(asset) ?? 0), 0);
26
- const select = (asset) => onAssetSelect ? () => onAssetSelect(asset) : undefined;
27
- return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [_jsxs(View, { testID: 'account-header', style: { flexDirection: 'row', alignItems: 'center', minHeight: 44 }, children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onBack ? _jsx(IconButton, { intent: 'ghost', label: t.back, suppressFeedback: true, testID: 'account-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'account-title', accessibilityRole: 'header', numberOfLines: 1, style: { flex: 1, textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: colors.text }, children: title ?? t.account }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: headerAction ?? (onShowAddress ? _jsx(IconButton, { intent: 'ghost', label: t.showAddress, testID: 'account-address', onPress: onShowAddress, children: _jsx(QrIcon, { color: colors.text }) }) : null) })] }), _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, marginTop: 8 }, children: [_jsx(View, { style: { flexShrink: 1 }, children: _jsx(AnimatedNumberReadout, { value: total, options: usd, label: t.accountBalance, testID: 'account-balance', style: { fontSize: 32, lineHeight: 40, fontWeight: '600' } }) }), onDeposit ? _jsx(Button, { testID: 'account-deposit', onPress: onDeposit, children: depositLabel ?? t.deposit }) : null] }), _jsxs(View, { testID: 'account-assets', style: { gap: 8, marginTop: 16 }, children: [_jsx(AssetBalanceRow, { testID: `account-asset-${pinned.id}`, name: pinned.name, symbol: pinned.symbol, icon: pinned.icon, value: assetValue(pinned), onSelect: select(pinned) }, pinned.id), rest.map(asset => _jsx(AssetBalanceRow, { testID: `account-asset-${asset.id}`, name: asset.name, symbol: asset.symbol, icon: asset.icon, value: assetValue(asset), balance: asset.balance ?? null, onSelect: select(asset) }, asset.id))] })] });
41
+ const shown = sections?.filter(section => section.assets.length > 0);
42
+ const total = balance !== undefined ? balance : shown ? accountSectionsTotal(shown) : sum(assets);
43
+ const row = (asset, pin, pinId, section, prefix = 'account-asset') => {
44
+ // A row pinned by symbol is the dollar balance, so its units would repeat its value; a row pinned by id keeps its own units setting.
45
+ const value = assetValue(asset), units = (!pin || asset.id === pinId) && asset.units !== false;
46
+ const select = onAssetSelect && asset.selectable !== false ? (section ? () => onAssetSelect(asset, section) : () => onAssetSelect(asset)) : undefined;
47
+ return _jsx(AssetBalanceRow, { testID: `${prefix}-${asset.id}`, name: asset.name, symbol: asset.symbol, icon: asset.icon, value: value, balance: units ? asset.balance ?? null : undefined, balanceOptions: asset.unitsOptions, unitsSuffix: asset.unitsSuffix, tag: asset.tag, headline: units && value === null && asset.balance != null && asset.unknownValue !== 'dash' ? 'units' : undefined, onSelect: select }, asset.id);
48
+ };
49
+ let list;
50
+ if (shown)
51
+ list = _jsx(View, { testID: 'account-sections', style: { gap: 24, marginTop: 16 }, children: shown.map(section => {
52
+ const pinId = section.pinnedId ?? pinnedId;
53
+ const { pinned, rest } = accountSectionRows(section.assets, pinnedSymbol, { order: section.order ?? order, pinnedId: pinId }), prefix = `account-section-${section.id}`, rowPrefix = `${prefix}-asset`;
54
+ return _jsxs(View, { testID: prefix, style: { gap: 8 }, children: [_jsxs(View, { testID: `${prefix}-header`, style: { flexDirection: 'row', alignItems: 'baseline', justifyContent: 'space-between', gap: 12, paddingHorizontal: 4 }, children: [_jsx(Text, { accessibilityRole: 'header', testID: `${prefix}-title`, style: { flexShrink: 1, color: colors.muted, fontSize: 14, lineHeight: 20, fontWeight: '500' }, children: section.title }), _jsx(AnimatedNumberReadout, { value: accountSectionTotal(section), options: usd, tone: 'muted', testID: `${prefix}-total`, style: { fontSize: 14, lineHeight: 20, fontWeight: '500' } })] }), _jsxs(View, { testID: `${prefix}-assets`, style: { gap: 8 }, children: [pinned ? row(pinned, true, pinId, section, rowPrefix) : null, rest.map(asset => row(asset, false, pinId, section, rowPrefix))] })] }, section.id);
55
+ }) });
56
+ else {
57
+ const { pinned, rest } = accountRows(assets, pinnedSymbol, { order, pinnedId });
58
+ list = _jsxs(View, { testID: 'account-assets', style: { gap: 8, marginTop: 16 }, children: [row(pinned, true, pinnedId), rest.map(asset => row(asset, false, pinnedId))] });
59
+ }
60
+ return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [_jsxs(View, { testID: 'account-header', style: { flexDirection: 'row', alignItems: 'center', minHeight: 44 }, children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onBack ? _jsx(IconButton, { intent: 'ghost', label: t.back, suppressFeedback: true, testID: 'account-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'account-title', accessibilityRole: 'header', numberOfLines: 1, style: { flex: 1, textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: colors.text }, children: title ?? t.account }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: headerAction ?? (onShowAddress ? _jsx(IconButton, { intent: 'ghost', label: t.showAddress, testID: 'account-address', onPress: onShowAddress, children: _jsx(QrIcon, { color: colors.text }) }) : null) })] }), _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, marginTop: 8 }, children: [_jsx(View, { style: { flexShrink: 1 }, children: _jsx(AnimatedNumberReadout, { value: total, options: usd, label: t.accountBalance, testID: 'account-balance', style: { fontSize: 32, lineHeight: 40, fontWeight: '600' } }) }), onDeposit ? _jsx(Button, { testID: 'account-deposit', onPress: onDeposit, children: depositLabel ?? t.deposit }) : null] }), list] });
28
61
  }
@@ -21,4 +21,10 @@ export interface NumberReelModel {
21
21
  export declare function formatNumberReadout(value: number | null | undefined, locale: string, options?: Intl.NumberFormatOptions, formattedValue?: string, prefix?: string, suffix?: string): NumberReading;
22
22
  export declare function numberTrendDirection(trend: NumberTrend | undefined, previousValue: number | null | undefined, value: number | null | undefined): -1 | 0 | 1;
23
23
  export declare function safeNumberLayout(text: string, direction: string): boolean;
24
- export declare function createNumberReelModel(value: number | null | undefined, locale: string, options: Intl.NumberFormatOptions | undefined, formattedValue: string | undefined, direction: string): NumberReelModel | null;
24
+ /**
25
+ * Reels for host-formatted text: every digit of `text` (ASCII, or the locale's own digits) becomes a reel keyed by its place
26
+ * counted from the end, and everything else stays as written. Used for a figure's `formattedValue` when the host formats
27
+ * numbers itself, for example because the runtime's Intl does not match its number table.
28
+ */
29
+ export declare function createFormattedReelModel(text: string, locale: string, direction: string): NumberReelModel | null;
30
+ export declare function createNumberReelModel(value: number | null | undefined, locale: string, options: Intl.NumberFormatOptions | undefined, formattedValue: string | undefined, direction: string, animateFormatted?: boolean): NumberReelModel | null;
@@ -44,7 +44,56 @@ export function safeNumberLayout(text, direction) {
44
44
  return false;
45
45
  return true;
46
46
  }
47
- export function createNumberReelModel(value, locale, options, formattedValue, direction) {
47
+ const asciiDigits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
48
+ /** The ten digit glyphs of a locale's numbering system, or `null` when Intl cannot name them one character each. */
49
+ function localeDigits(locale) {
50
+ try {
51
+ const numberingSystem = new Intl.NumberFormat(locale).resolvedOptions().numberingSystem;
52
+ const digitFormatter = new Intl.NumberFormat(locale, { numberingSystem, useGrouping: false, minimumFractionDigits: 0, maximumFractionDigits: 0 });
53
+ const digits = Array.from({ length: 10 }, (_, digit) => { const formatted = digitFormatter.format(digit); return Array.from(formatted).length === 1 ? formatted : ''; });
54
+ return digits.every(Boolean) && new Set(digits).size === 10 ? digits : null;
55
+ }
56
+ catch {
57
+ return null;
58
+ }
59
+ }
60
+ /**
61
+ * Reels for host-formatted text: every digit of `text` (ASCII, or the locale's own digits) becomes a reel keyed by its place
62
+ * counted from the end, and everything else stays as written. Used for a figure's `formattedValue` when the host formats
63
+ * numbers itself, for example because the runtime's Intl does not match its number table.
64
+ */
65
+ export function createFormattedReelModel(text, locale, direction) {
66
+ if (!text || !safeNumberLayout(text, direction))
67
+ return null;
68
+ const characters = Array.from(text), ascii = characters.some(character => asciiDigits.includes(character));
69
+ const digits = ascii ? asciiDigits : localeDigits(locale);
70
+ if (!digits)
71
+ return null;
72
+ const count = characters.filter(character => digits.includes(character)).length;
73
+ if (!count)
74
+ return null;
75
+ const tokens = [];
76
+ let run = '', seen = 0;
77
+ const flush = () => { if (run) {
78
+ tokens.push({ key: `static:${tokens.length}`, kind: 'static', type: 'literal', value: run, partIndex: tokens.length });
79
+ run = '';
80
+ } };
81
+ for (const character of characters) {
82
+ const digit = digits.indexOf(character);
83
+ if (digit < 0) {
84
+ run += character;
85
+ continue;
86
+ }
87
+ flush();
88
+ const place = count - ++seen;
89
+ tokens.push({ key: `digit:${place}`, kind: 'digit', type: 'integer', value: character, partIndex: tokens.length, digit, place });
90
+ }
91
+ flush();
92
+ return { canonical: text, digits, tokens };
93
+ }
94
+ export function createNumberReelModel(value, locale, options, formattedValue, direction, animateFormatted = false) {
95
+ if (typeof value === 'number' && Number.isFinite(value) && formattedValue && animateFormatted && typeof Intl !== 'undefined')
96
+ return createFormattedReelModel(formattedValue, locale, direction);
48
97
  if (typeof value !== 'number' || !Number.isFinite(value) || formattedValue || direction !== 'ltr' || typeof Intl === 'undefined' || typeof Intl.NumberFormat !== 'function')
49
98
  return null;
50
99
  try {
@@ -5,5 +5,7 @@ export type AnimatedNumberTrend = NumberTrend;
5
5
  export interface AnimatedNumberProps extends NumberProps {
6
6
  duration?: number;
7
7
  trend?: AnimatedNumberTrend;
8
+ /** With `formattedValue`, moves the host's text place by place: each digit it contains rolls in place, counted from the end, and the rest stays as written. Without it `formattedValue` is drawn static, as before. */
9
+ animateFormatted?: boolean;
8
10
  }
9
- export declare function AnimatedNumberReadout({ value, options, formattedValue, stale, label, tone, style, testID, maxFontSizeMultiplier, trend, prefix, suffix, duration }: AnimatedNumberProps): React.JSX.Element;
11
+ export declare function AnimatedNumberReadout({ value, options: requested, formattedValue, animateFormatted, stale, label, tone, style, testID, maxFontSizeMultiplier, trend, prefix, suffix, duration }: AnimatedNumberProps): React.JSX.Element;
@@ -4,9 +4,10 @@ import { useEffect, useRef, useState } from 'react';
4
4
  import { PixelRatio, StyleSheet, View } from 'react-native';
5
5
  import Reanimated, { cancelAnimation, Easing, ReduceMotion, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
6
6
  import * as en from '@bloxwap/hig/contracts/messages';
7
+ import { presentNumberFormat } from '@bloxwap/hig/contracts';
7
8
  import { tokens } from '@bloxwap/hig/tokens';
8
9
  import { createNumberReelModel, formatNumberReadout, numberTrendDirection, safeNumberLayout } from './animated-number-model.js';
9
- import { useColors, useHIG } from './provider.js';
10
+ import { useColors, useHIG, useNumberLocale } from './provider.js';
10
11
  import { detectScript, Text } from './surface.js';
11
12
  const numberTypographyKeys = new Set(['fontFamily', 'fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'textAlign']);
12
13
  // Android Fabric reads colour 0 as "unset", so 'transparent' (0x00000000) drew the hidden reading in the default
@@ -68,16 +69,18 @@ function recordGlyph(measurements, key, index, event, setMetrics) {
68
69
  return;
69
70
  setMetrics(current => current?.key === key && current.width === measuredWidth && current.height === measuredHeight ? current : { key, width: measuredWidth, height: measuredHeight });
70
71
  }
71
- export function AnimatedNumberReadout({ value, options, formattedValue, stale, label, tone = 'text', style, testID, maxFontSizeMultiplier, trend, prefix, suffix, duration = 180 }) {
72
- const { locale, messages, direction, reducedMotion, fontFamily, fontFamilies, fontFamiliesByScript, letterSpacingByScript, maxFontSizeMultiplier: providerMaxFontSizeMultiplier } = useHIG(), colors = useColors();
72
+ export function AnimatedNumberReadout({ value, options: requested, formattedValue, animateFormatted, stale, label, tone = 'text', style, testID, maxFontSizeMultiplier, trend, prefix, suffix, duration = 180 }) {
73
+ const locale = useNumberLocale();
74
+ const { messages, direction, reducedMotion, fontFamily, fontFamilies, fontFamiliesByScript, letterSpacingByScript, maxFontSizeMultiplier: providerMaxFontSizeMultiplier, numberFormat } = useHIG(), colors = useColors();
75
+ const options = presentNumberFormat(requested, numberFormat);
73
76
  const reading = formatNumberReadout(value, locale, options, formattedValue, prefix, suffix), staleSuffix = stale ? ` ${messages.stale ?? en.stale}` : '';
74
77
  const previousValue = useRef(value), directionTrend = numberTrendDirection(trend, previousValue.current, value);
75
78
  useEffect(() => { previousValue.current = value; }, [value]);
76
79
  const typography = Object.fromEntries(Object.entries(StyleSheet.flatten(style) ?? {}).filter(([key]) => numberTypographyKeys.has(key)));
77
- const color = colors[tone === 'positive' || tone === 'negative' || tone === 'muted' || tone === 'up' || tone === 'down' ? tone : 'text'];
80
+ const color = colors[tone === 'positive' || tone === 'negative' || tone === 'warning' || tone === 'muted' || tone === 'faint' || tone === 'up' || tone === 'down' ? tone : 'text'];
78
81
  const textStyle = [typography, { color, fontVariant: ['tabular-nums'] }];
79
82
  const script = detectScript(`${reading.text}${staleSuffix}`, locale);
80
- const model = createNumberReelModel(value, locale, options, formattedValue, direction);
83
+ const model = createNumberReelModel(value, locale, options, formattedValue, direction, animateFormatted);
81
84
  const safeModel = model && safeNumberLayout(`${prefix ?? ''}${suffix ?? ''}${staleSuffix}`, direction) ? model : null;
82
85
  let fontScale = 0;
83
86
  try {
@@ -12,9 +12,25 @@ export interface AssetBalanceRowProps {
12
12
  balance?: number | null;
13
13
  /** Format of the units line; default `{maximumFractionDigits:6}`. */
14
14
  balanceOptions?: Intl.NumberFormatOptions;
15
+ /** Host text after the units figure, such as ` HYPE`. Drawn and read only when the units are known. */
16
+ unitsSuffix?: string;
17
+ /** `units` puts the units on the headline line in place of the value and draws no second line, for a holding with no dollar value. Default `value`. */
18
+ headline?: 'value' | 'units';
19
+ /** `false` draws no figures at all, for a row that is just an item to pick, such as a method or a chain. Default `true`. */
20
+ amounts?: boolean;
21
+ /** Short muted host text under the figures, such as the ledger a holding sits in. Read after them. */
22
+ tag?: string;
23
+ /** Host content on the trailing edge, after the figures. Inside a pressable row it must not be interactive. The row reads it as one label, last: its text, or `trailingLabel`. */
24
+ trailing?: React.ReactNode;
25
+ /** What the row reads for `trailing`, in place of its text, for an icon or a figure whose text is not what should be heard. */
26
+ trailingLabel?: string;
27
+ /** Marks the row in use: a check on the trailing edge and `accessibilityState.selected`. */
28
+ selected?: boolean;
29
+ /** Dims the row, ignores presses and reads as unavailable. */
30
+ disabled?: boolean;
15
31
  /** Makes the row a button. */
16
32
  onSelect?: () => void;
17
33
  testID?: string;
18
34
  }
19
35
  /** One holding as a capsule row: a round avatar, the asset's name over its symbol, and its dollar value over its units. The avatar is padded equally on every side, so the capsule end is concentric with it, and both numbers update place by place. */
20
- export declare function AssetBalanceRow({ name, symbol, icon, value, balance, balanceOptions, onSelect, testID }: AssetBalanceRowProps): React.JSX.Element;
36
+ export declare function AssetBalanceRow({ name, symbol, icon, value, balance, balanceOptions, unitsSuffix, headline, amounts, tag, trailing, trailingLabel, selected, disabled, onSelect, testID }: AssetBalanceRowProps): React.JSX.Element;
@@ -1,21 +1,26 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Image, Pressable, View } from 'react-native';
3
- import { useColors, useFills, useHIG } from './provider.js';
3
+ import { useColors, useFills, useNumberLocale, usePresentNumber } from './provider.js';
4
4
  import { Text } from './surface.js';
5
5
  import { AnimatedNumberReadout } from './animated-number.js';
6
6
  import { formatNumberReadout } from './animated-number-model.js';
7
+ import { plainText } from './text-content.js';
7
8
  const usd = { style: 'currency', currency: 'USD' };
8
9
  const units = { maximumFractionDigits: 6 };
9
10
  const avatar = 40;
10
11
  const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
11
12
  /** One holding as a capsule row: a round avatar, the asset's name over its symbol, and its dollar value over its units. The avatar is padded equally on every side, so the capsule end is concentric with it, and both numbers update place by place. */
12
- export function AssetBalanceRow({ name, symbol, icon, value, balance, balanceOptions = units, onSelect, testID }) {
13
- const colors = useColors(), fills = useFills(), { locale } = useHIG();
14
- const hasUnits = balance !== undefined;
15
- const label = [name, symbol, formatNumberReadout(value, locale, usd).text, hasUnits ? formatNumberReadout(balance, locale, balanceOptions).text : null].filter(Boolean).join(', ');
13
+ export function AssetBalanceRow({ name, symbol, icon, value, balance, balanceOptions = units, unitsSuffix, headline = 'value', amounts = true, tag, trailing, trailingLabel, selected, disabled, onSelect, testID }) {
14
+ const colors = useColors(), fills = useFills(), locale = useNumberLocale(), present = usePresentNumber();
15
+ const unitsFirst = headline === 'units', hasUnits = amounts && !unitsFirst && balance !== undefined;
16
+ const unitsText = () => formatNumberReadout(balance, locale, balanceOptions, undefined, undefined, unitsSuffix).text;
17
+ const headlineText = amounts ? unitsFirst ? unitsText() : formatNumberReadout(value, locale, present(usd)).text : null;
18
+ const label = [name, symbol, headlineText, hasUnits ? unitsText() : null, tag || null, trailingLabel ?? (trailing != null && trailing !== false ? plainText(trailing) : null)].filter(Boolean).join(', ');
19
+ const state = selected || disabled ? { ...(selected ? { selected: true } : {}), ...(disabled ? { disabled: true } : {}) } : undefined;
20
+ const strong = disabled ? colors.muted : colors.text;
16
21
  const shape = { width: avatar, height: avatar, borderRadius: avatar / 2, backgroundColor: fills.raised, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' };
17
22
  const art = typeof icon === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: icon }, style: shape }) : _jsx(View, { style: shape, children: icon ?? _jsx(Text, { accessible: false, maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: symbol.slice(0, 3) }) });
18
- const row = (pressed) => ({ flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 56, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 28, backgroundColor: pressed ? fills.raised : fills.well });
19
- const content = _jsxs(_Fragment, { children: [_jsx(View, { ...hidden, children: art }), _jsxs(View, { ...hidden, style: { flex: 1, flexShrink: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.text }, children: name }), _jsx(Text, { numberOfLines: 1, style: { fontSize: 14, lineHeight: 20, color: colors.muted }, children: symbol })] }), _jsxs(View, { ...hidden, style: { alignItems: 'flex-end', justifyContent: 'center' }, children: [_jsx(AnimatedNumberReadout, { value: value, options: usd, testID: testID ? `${testID}-value` : undefined, style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }), hasUnits ? _jsx(AnimatedNumberReadout, { value: balance, options: balanceOptions, tone: 'muted', testID: testID ? `${testID}-balance` : undefined, style: { fontSize: 14, lineHeight: 20 } }) : null] })] });
20
- return onSelect ? _jsx(Pressable, { testID: testID, accessibilityRole: 'button', accessibilityLabel: label, onPress: onSelect, style: ({ pressed }) => row(pressed), children: content }) : _jsx(View, { testID: testID, accessible: true, accessibilityLabel: label, style: row(false), children: content });
23
+ const row = (pressed) => ({ flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 56, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 28, backgroundColor: pressed && !disabled ? fills.raised : fills.well });
24
+ const content = _jsxs(_Fragment, { children: [_jsx(View, { ...hidden, style: disabled ? { opacity: 0.5 } : undefined, children: art }), _jsxs(View, { ...hidden, style: { flex: 1, flexShrink: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { fontSize: 16, lineHeight: 24, fontWeight: '600', color: strong }, children: name }), _jsx(Text, { numberOfLines: 1, style: { fontSize: 14, lineHeight: 20, color: colors.muted }, children: symbol })] }), amounts || tag ? _jsxs(View, { ...hidden, style: { alignItems: 'flex-end', justifyContent: 'center' }, children: [amounts ? unitsFirst ? _jsx(AnimatedNumberReadout, { value: balance, options: balanceOptions, suffix: unitsSuffix, tone: disabled ? 'muted' : undefined, testID: testID ? `${testID}-balance` : undefined, style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) : _jsx(AnimatedNumberReadout, { value: value, options: usd, tone: disabled ? 'muted' : undefined, testID: testID ? `${testID}-value` : undefined, style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) : null, hasUnits ? _jsx(AnimatedNumberReadout, { value: balance, options: balanceOptions, suffix: unitsSuffix, tone: 'muted', testID: testID ? `${testID}-balance` : undefined, style: { fontSize: 14, lineHeight: 20 } }) : null, tag ? _jsx(Text, { testID: testID ? `${testID}-tag` : undefined, numberOfLines: 1, style: { fontSize: 12, lineHeight: 18, color: colors.muted }, children: tag }) : null] }) : null, trailing != null && trailing !== false ? _jsx(View, { ...hidden, testID: testID ? `${testID}-trailing` : undefined, style: { flexDirection: 'row', alignItems: 'center', gap: 8 }, children: trailing }) : null, selected ? _jsx(View, { ...hidden, testID: testID ? `${testID}-check` : undefined, style: { width: 20, height: 20, alignItems: 'center', justifyContent: 'center' }, children: _jsx(View, { style: { width: 6, height: 12, borderRightWidth: 2, borderBottomWidth: 2, borderColor: strong, transform: [{ translateY: -1 }, { rotate: '45deg' }] } }) }) : null] });
25
+ return onSelect ? _jsx(Pressable, { testID: testID, accessibilityRole: 'button', accessibilityLabel: label, accessibilityState: state, disabled: disabled, onPress: onSelect, style: ({ pressed }) => row(pressed), children: content }) : _jsx(View, { testID: testID, accessible: true, accessibilityLabel: label, accessibilityState: state, style: row(false), children: content });
21
26
  }
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { type Figure } from './figure.js';
2
3
  /** Colour roles a segment can take. They follow the provider's colour space and market colours as those roles do. */
3
4
  export type BarMarkTone = 'positive' | 'info' | 'warning' | 'negative' | 'muted' | 'faint';
4
5
  export interface BarMarkElement {
@@ -11,9 +12,20 @@ export interface BarMarkElement {
11
12
  tone?: BarMarkTone;
12
13
  /** A host colour for this segment; wins over `tone`. */
13
14
  color?: string;
14
- /** Host-formatted amount shown after the label in the legend, such as `12.4 GB`. */
15
- detail?: string;
15
+ /** Amount shown after the label in the legend: host-formatted text, such as `12.4 GB`, or a live figure. */
16
+ detail?: string | BarMarkFigure;
16
17
  }
18
+ /** A legend amount that can change while the bar is shown: formatted with `options` between `prefix` and `suffix`. `null` reads as unknown. */
19
+ export type BarMarkFigure = Figure;
20
+ /**
21
+ * Draws a live legend figure. The bar-mark entry imports no animation engine, so without a renderer a figure is drawn
22
+ * formatted, without movement. `TokenActionBlock` supplies one that moves place by place through `AnimatedNumberReadout`,
23
+ * and a host that installs the animated-number peers can do the same around its own `BarMark`.
24
+ */
25
+ export type BarMarkFigureRenderer = (figure: BarMarkFigure, props: {
26
+ testID?: string;
27
+ }) => React.ReactNode;
28
+ export declare const BarMarkFigureContext: React.Context<BarMarkFigureRenderer | null>;
17
29
  export interface BarMarkProps {
18
30
  title: string;
19
31
  /** Trailing text on the title row, such as `59.2 GB of 64 GB`. A string is drawn muted; an element is rendered as given. */
@@ -1,8 +1,11 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useContext } from 'react';
2
3
  import { View } from 'react-native';
3
4
  import { formatNumber } from '@bloxwap/hig/contracts';
4
- import { useColors, useFills, useHIG } from './provider.js';
5
+ import { useColors, useFills, useHIG, useNumberLocale, usePresentNumber } from './provider.js';
6
+ import { figureReading } from './figure.js';
5
7
  import { Surface, Text } from './surface.js';
8
+ export const BarMarkFigureContext = React.createContext(null);
6
9
  /** The order segments take their colour in when an element names neither `tone` nor `color`. */
7
10
  export const barMarkTones = ['positive', 'info', 'warning', 'negative', 'muted', 'faint'];
8
11
  const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
@@ -23,12 +26,23 @@ function Bar({ elements, values, rest, colors, small, testID }) {
23
26
  * label, detail and share. Layout follows the provider's direction.
24
27
  */
25
28
  export function BarMark({ title, description, elements, total, legend = true, size = 'default', surface = true, testID }) {
26
- const { locale, direction } = useHIG();
27
- const palette = useColors();
29
+ const { direction } = useHIG();
30
+ const locale = useNumberLocale(), palette = useColors(), present = usePresentNumber(), renderFigure = useContext(BarMarkFigureContext);
28
31
  const { values, shares, rest } = barMarkShares(elements, total);
29
32
  const colors = elements.map((element, index) => element.color ?? palette[element.tone ?? barMarkTones[index % barMarkTones.length]]);
30
- const reading = (element, index) => [element.label, element.detail, formatNumber(shares[index], locale, { style: 'percent', maximumFractionDigits: 1 })].filter(Boolean).join(', ');
33
+ const detailText = (detail) => detail == null || typeof detail === 'string' ? detail : figureReading(detail, locale, present(detail.options));
34
+ const reading = (element, index) => [element.label, detailText(element.detail), formatNumber(shares[index], locale, { style: 'percent', maximumFractionDigits: 1 })].filter(Boolean).join(', ');
35
+ const detailStyle = { color: palette.faint, fontSize: 14, lineHeight: 21 };
36
+ const detail = (element, index) => {
37
+ const value = element.detail;
38
+ if (!value)
39
+ return null;
40
+ const id = testID ? `${testID}-detail-${element.id ?? index}` : undefined;
41
+ if (typeof value === 'string')
42
+ return _jsx(Text, { style: detailStyle, children: value });
43
+ return renderFigure ? renderFigure(value, { testID: id }) : _jsx(Text, { testID: id, style: detailStyle, children: detailText(value) });
44
+ };
31
45
  const group = legend ? {} : { accessible: true, accessibilityLabel: [title, ...elements.map(reading)].join(', ') };
32
- const content = _jsxs(_Fragment, { children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', justifyContent: 'space-between', gap: 12 }, children: [_jsx(Text, { style: { fontSize: 16, lineHeight: 24, fontWeight: '600', flexShrink: 1 }, children: title }), description == null || description === false ? null : typeof description === 'string' || typeof description === 'number' ? _jsx(Text, { style: { color: palette.muted, fontSize: 14, lineHeight: 21, flexShrink: 1 }, children: description }) : description] }), _jsx(Bar, { elements: elements, values: values, rest: rest, colors: colors, small: size === 'small', testID: testID }), legend ? _jsx(View, { style: { flexDirection: 'row', flexWrap: 'wrap', columnGap: 16, rowGap: 8 }, children: elements.map((element, index) => _jsxs(View, { accessible: true, accessibilityLabel: reading(element, index), testID: testID ? `${testID}-legend-${element.id ?? index}` : undefined, style: { flexDirection: 'row', alignItems: 'center', gap: 6 }, children: [_jsx(View, { style: { width: 8, height: 8, borderRadius: 4, backgroundColor: colors[index] } }), _jsx(Text, { style: { color: palette.muted, fontSize: 14, lineHeight: 21 }, children: element.label }), element.detail ? _jsx(Text, { style: { color: palette.faint, fontSize: 14, lineHeight: 21 }, children: element.detail }) : null] }, element.id ?? index)) }) : null] });
46
+ const content = _jsxs(_Fragment, { children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', justifyContent: 'space-between', gap: 12 }, children: [_jsx(Text, { style: { fontSize: 16, lineHeight: 24, fontWeight: '600', flexShrink: 1 }, children: title }), description == null || description === false ? null : typeof description === 'string' || typeof description === 'number' ? _jsx(Text, { style: { color: palette.muted, fontSize: 14, lineHeight: 21, flexShrink: 1 }, children: description }) : description] }), _jsx(Bar, { elements: elements, values: values, rest: rest, colors: colors, small: size === 'small', testID: testID }), legend ? _jsx(View, { style: { flexDirection: 'row', flexWrap: 'wrap', columnGap: 16, rowGap: 8 }, children: elements.map((element, index) => _jsxs(View, { accessible: true, accessibilityLabel: reading(element, index), testID: testID ? `${testID}-legend-${element.id ?? index}` : undefined, style: { flexDirection: 'row', alignItems: 'center', gap: 6 }, children: [_jsx(View, { style: { width: 8, height: 8, borderRadius: 4, backgroundColor: colors[index] } }), _jsx(Text, { style: { color: palette.muted, fontSize: 14, lineHeight: 21 }, children: element.label }), detail(element, index)] }, element.id ?? index)) }) : null] });
33
47
  return surface ? _jsx(Surface, { testID: testID, style: { gap: 12 }, ...group, children: content }) : _jsx(View, { testID: testID, style: { direction, gap: 12, minWidth: 0 }, ...group, children: content });
34
48
  }