@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
@@ -1,10 +1,11 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Image, View } from 'react-native';
3
- import { useColors, useFills, useHIG, useMessages } from './provider.js';
3
+ import { useColors, useFills, useHIG, useNumberLocale } from './provider.js';
4
4
  import { Text } from './surface.js';
5
5
  import { BarPnl } from './bar-pnl.js';
6
- import { Button, IconButton } from './button.js';
7
- import { ChevronIcon } from './icons.js';
6
+ import { Button } from './button.js';
7
+ import { ScreenHeader } from './screen-header.js';
8
+ import { StickyHeaderLayout } from './sticky-header.js';
8
9
  import { AnimatedNumberReadout } from './animated-number.js';
9
10
  import { formatNumberReadout } from './animated-number-model.js';
10
11
  const pnlUsd = { style: 'currency', currency: 'USD', signDisplay: 'exceptZero', maximumFractionDigits: 4 };
@@ -24,15 +25,22 @@ function Sentence({ template, text, value, options, tone, testID }) {
24
25
  return _jsxs(View, { accessible: true, accessibilityLabel: reading, testID: testID, style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', flexShrink: 1 }, children: [parts[0] ? _jsx(Text, { accessible: false, style: words, children: parts[0] }) : null, _jsx(AnimatedNumberReadout, { value: value, options: options, tone: tone, style: type }), parts[1] ? _jsx(Text, { accessible: false, style: words, children: parts[1] }) : null] });
25
26
  }
26
27
  /** The full record of one closed trade, drawn on the screen without cards because none of it is pressable: the asset with its side and leverage on one line, the net profit and loss with its return on margin, a bar from the entry price to the exit price, the host's other figures as a compact grid, and the host's actions side by side. */
27
- export function TradeHistoryDetailBlock({ labels, name, icon, side, leverage, pnl, pnlPercent, entry, exit, priceOptions, details, actions = [], onBack, headerAction, testID }) {
28
- const colors = useColors(), fills = useFills(), t = useMessages(), { direction, locale } = useHIG();
28
+ export function TradeHistoryDetailBlock({ labels, name, icon, symbol, side, leverage, leverageNote, pnl, pnlOptions = pnlUsd, pnlPercent, percentOptions = pnlShare, entry, exit, priceOptions, details, note, badge, summaryRef, summaryBackground, actions = [], onBack, headerAction, stickyHeader, stickyHeaderBackground, scrollComponent, testID }) {
29
+ const colors = useColors(), fills = useFills(), { direction } = useHIG(), locale = useNumberLocale();
29
30
  const long = side === 'long', word = long ? labels.long : labels.short, tint = long ? colors.up : colors.down;
30
31
  const tone = known(pnl) && pnl > 0 ? 'up' : known(pnl) && pnl < 0 ? 'down' : 'text';
31
32
  const turns = known(leverage) ? formatNumberReadout(leverage, locale, gearing).text + times : null;
32
33
  const shape = { width: avatar, height: avatar, borderRadius: avatar / 2, backgroundColor: fills.raised, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' };
33
- 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: 9, lineHeight: 12, fontWeight: '600', color: colors.muted }, children: name.slice(0, 3) }) });
34
+ 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: 9, lineHeight: 12, fontWeight: '600', color: colors.muted }, children: symbol ?? name.slice(0, 3) }) });
34
35
  const meta = { fontSize: 14, lineHeight: 20 };
36
+ // The summary gets a wrapper only when the host asks for a ref to capture it, so the default tree is unchanged.
37
+ const fill = summaryBackground === true ? colors.background : typeof summaryBackground === 'string' && summaryBackground ? summaryBackground : undefined;
38
+ const wrap = (summary) => summaryRef ? _jsx(View, { ref: summaryRef, collapsable: false, testID: 'trade-summary', style: fill ? { backgroundColor: fill } : undefined, children: summary }) : summary;
35
39
  // Three figures to a line: a small label over its value.
36
- const rows = details.map(detail => _jsxs(View, { testID: `trade-detail-${detail.label}`, style: { width: '33.333%', paddingEnd: 8, gap: 2 }, children: [_jsx(Text, { numberOfLines: 1, style: { fontSize: 12, lineHeight: 16, color: colors.muted }, children: detail.label }), typeof detail.value === 'number' ? _jsx(AnimatedNumberReadout, { value: detail.value, options: detail.options, prefix: detail.prefix, suffix: detail.suffix, tone: 'text', style: { fontSize: 15, lineHeight: 22, fontWeight: '600' } }) : _jsx(Text, { style: { fontSize: 15, lineHeight: 22, fontWeight: '600', color: colors.text }, children: detail.value })] }, detail.label));
37
- return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [_jsxs(View, { testID: 'trade-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: 'trade-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'trade-title', accessibilityRole: 'header', numberOfLines: 1, style: { flex: 1, textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: colors.text }, children: labels.title }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: headerAction })] }), _jsxs(View, { testID: 'trade-asset', accessible: true, accessibilityLabel: [name, word, turns].filter(Boolean).join(', '), style: { direction, flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'center', gap: 8, marginTop: 16 }, children: [_jsx(View, { ...hidden, children: art }), _jsx(Text, { ...hidden, numberOfLines: 1, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.text }, children: name }), _jsx(View, { ...hidden, children: _jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', gap: 4 }, children: [_jsx(Text, { testID: 'trade-side-arrow', style: { ...meta, fontWeight: '600', color: tint }, children: long ? up : down }), _jsx(Text, { testID: 'trade-side', style: { ...meta, fontWeight: '600', color: tint, textTransform: 'uppercase' }, children: word }), turns ? _jsx(Text, { testID: 'trade-leverage', style: { ...meta, color: colors.muted }, children: turns }) : null] }) })] }), _jsxs(View, { testID: 'trade-pnl', style: { alignItems: 'center', gap: 4, marginTop: 8 }, children: [_jsx(AnimatedNumberReadout, { testID: 'trade-pnl-value', label: labels.netPnl, value: pnl, options: pnlUsd, tone: tone, style: { fontSize: 40, lineHeight: 48, fontWeight: '700' } }), pnlPercent !== undefined ? _jsx(Sentence, { testID: 'trade-pnl-percent', template: labels.onMargin, text: known(pnlPercent) ? formatNumberReadout(pnlPercent, locale, pnlShare).text : unknown, value: known(pnlPercent) ? pnlPercent : null, options: pnlShare, tone: tone }) : null] }), known(entry) && known(exit) ? _jsx(View, { style: { marginTop: 20, paddingHorizontal: 4 }, children: _jsx(BarPnl, { testID: 'trade-bar', surface: false, fit: true, side: side, entry: entry, mark: exit, labels: { entry: labels.entry ?? empty, mark: labels.exit ?? empty, liquidation: empty }, priceOptions: priceOptions }) }) : null, details.length > 0 ? _jsx(View, { testID: 'trade-details', style: { direction, flexDirection: 'row', flexWrap: 'wrap', rowGap: 16, marginTop: 20, paddingHorizontal: 4 }, children: rows }) : null, actions.length > 0 ? _jsx(View, { testID: 'trade-actions', style: { direction, flexDirection: 'row', gap: 8, marginTop: 16 }, children: actions.map(action => _jsx(View, { style: { flex: 1, minWidth: 0 }, children: _jsx(Button, { fullWidth: true, testID: `trade-action-${action.id}`, intent: action.intent ?? 'secondary', disabled: action.disabled, busy: action.busy, onPress: action.onSelect, children: action.label }) }, action.id)) }) : null] });
40
+ const rows = details.map(detail => _jsxs(View, { testID: `trade-detail-${detail.label}`, style: { width: '33.333%', paddingEnd: 8, gap: 2 }, children: [_jsx(Text, { numberOfLines: 1, style: { fontSize: 12, lineHeight: 16, color: colors.muted }, children: detail.label }), typeof detail.value === 'number' ? _jsx(AnimatedNumberReadout, { value: detail.value, options: detail.options, prefix: detail.prefix, suffix: detail.suffix, formattedValue: detail.formattedValue, animateFormatted: !!detail.formattedValue, tone: 'text', style: { fontSize: 15, lineHeight: 22, fontWeight: '600' } }) : _jsx(Text, { style: { fontSize: 15, lineHeight: 22, fontWeight: '600', color: colors.text }, children: detail.value })] }, detail.label));
41
+ const header = _jsx(ScreenHeader, { testID: 'trade', title: labels.title, badge: badge, onBack: onBack, action: headerAction });
42
+ const body = _jsxs(_Fragment, { children: [wrap(_jsxs(_Fragment, { children: [_jsxs(View, { testID: 'trade-asset', accessible: true, accessibilityLabel: [name, word, turns, leverageNote].filter(Boolean).join(', '), style: { direction, flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'center', gap: 8, marginTop: 16 }, children: [_jsx(View, { ...hidden, children: art }), _jsx(Text, { ...hidden, numberOfLines: 1, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.text }, children: name }), _jsx(View, { ...hidden, children: _jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', gap: 4 }, children: [_jsx(Text, { testID: 'trade-side-arrow', style: { ...meta, fontWeight: '600', color: tint }, children: long ? up : down }), _jsx(Text, { testID: 'trade-side', style: { ...meta, fontWeight: '600', color: tint, textTransform: 'uppercase' }, children: word }), turns ? _jsx(Text, { testID: 'trade-leverage', style: { ...meta, color: colors.muted }, children: turns }) : null, leverageNote ? _jsx(Text, { testID: 'trade-leverage-note', style: { ...meta, color: colors.muted }, children: leverageNote }) : null] }) })] }), _jsxs(View, { testID: 'trade-pnl', style: { alignItems: 'center', gap: 4, marginTop: 8 }, children: [_jsx(AnimatedNumberReadout, { testID: 'trade-pnl-value', label: labels.netPnl, value: pnl, options: pnlOptions, tone: tone, style: { fontSize: 40, lineHeight: 48, fontWeight: '700' } }), pnlPercent !== undefined ? _jsx(Sentence, { testID: 'trade-pnl-percent', template: labels.onMargin, text: known(pnlPercent) ? formatNumberReadout(pnlPercent, locale, percentOptions).text : unknown, value: known(pnlPercent) ? pnlPercent : null, options: percentOptions, tone: tone }) : null] })] })), known(entry) && known(exit) ? _jsx(View, { style: { marginTop: 20, paddingHorizontal: 4 }, children: _jsx(BarPnl, { testID: 'trade-bar', surface: false, fit: true, side: side, entry: entry, mark: exit, labels: { entry: labels.entry ?? empty, mark: labels.exit ?? empty, liquidation: empty }, priceOptions: priceOptions }) }) : null, details.length > 0 ? _jsx(View, { testID: 'trade-details', style: { direction, flexDirection: 'row', flexWrap: 'wrap', rowGap: 16, marginTop: 20, paddingHorizontal: 4 }, children: rows }) : null, note ? _jsx(Text, { testID: 'trade-note', style: { marginTop: 16, paddingHorizontal: 4, fontSize: 14, lineHeight: 21, color: colors.muted }, children: note }) : null, actions.length > 0 ? _jsx(View, { testID: 'trade-actions', style: { direction, flexDirection: 'row', gap: 8, marginTop: 16 }, children: actions.map(action => _jsx(View, { style: { flex: 1, minWidth: 0 }, children: _jsx(Button, { fullWidth: true, testID: `trade-action-${action.id}`, intent: action.intent ?? 'secondary', disabled: action.disabled, busy: action.busy, onPress: action.onSelect, children: action.label }) }, action.id)) }) : null] });
43
+ if (stickyHeader)
44
+ return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: 'trade-sticky-header', header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: body });
45
+ return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [header, body] });
38
46
  }
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { type NativeScrollEvent, type NativeSyntheticEvent, type ScrollViewProps, type ViewStyle } from 'react-native';
2
3
  import type { AssetArtwork } from './asset-balance-row.js';
3
4
  /** The words of the block. They are trading terms, so the host supplies them; HIG ships none. */
4
5
  export interface TradeHistoryListLabels {
@@ -8,21 +9,55 @@ export interface TradeHistoryListLabels {
8
9
  short: string;
9
10
  /** Shown in place of the rows when there are no trades. */
10
11
  empty: string;
12
+ /** A second line under `empty`, in the muted colour: Closed trades appear here. */
13
+ emptyDescription?: string;
11
14
  }
12
15
  /** One closed trade. */
13
16
  export interface TradeHistoryItem {
14
17
  id: string;
15
18
  /** Asset name: Amazon. */
16
19
  name: string;
17
- /** Round artwork: an image URL or a host element. Without it the row shows the first letters of the name. */
20
+ /** Short ticker for the fallback disc when there is no `icon`: BTC. Without it the disc shows the first letters of the name. */
21
+ symbol?: string;
22
+ /** Round artwork: an image URL or a host element. Without it the row shows `symbol` or the first letters of the name. */
18
23
  icon?: AssetArtwork;
19
24
  side: 'long' | 'short';
20
25
  /** 20 reads `20×`. */
21
26
  leverage?: number;
27
+ /** A short muted qualifier after the leverage, read with it: current. Use it when the leverage was not recorded with the trade. */
28
+ leverageNote?: string;
22
29
  /** Net profit and loss in dollars. `null` reads as unknown. */
23
30
  pnl: number | null;
24
31
  /** Host-formatted age or time of the close, shown under the result: `2d`. */
25
32
  time?: string;
33
+ /** Small muted host text before the age, such as the wallet the trade came from: `0x22…22`. */
34
+ tag?: string;
35
+ /** Format of this trade's result, in place of the block's `pnlOptions`, for a host whose decimal ladder depends on the amount. */
36
+ pnlOptions?: Intl.NumberFormatOptions;
37
+ }
38
+ /**
39
+ * What `renderList` receives, shaped for FlatList so `{...list}` spreads onto it: the trades and helpers that draw them exactly
40
+ * as the block does. With `listChrome` it also carries everything around them, so the list holds the whole screen and a sheet
41
+ * that sizes itself to its content measures the list alone.
42
+ */
43
+ export interface TradeHistoryListRender {
44
+ trades: readonly TradeHistoryItem[];
45
+ /** Draws one row; the signature matches FlatList's `renderItem`. */
46
+ renderItem: (info: {
47
+ item: TradeHistoryItem;
48
+ }) => React.ReactElement;
49
+ keyExtractor: (trade: TradeHistoryItem) => string;
50
+ /** The 8dp gap between rows, for `ItemSeparatorComponent`. */
51
+ ItemSeparatorComponent: React.ComponentType;
52
+ /** With `listChrome`: the header (unless it is pinned with `stickyHeader`) and the `notice`, 16dp above the first row. `null` when there is neither. */
53
+ ListHeaderComponent?: React.ReactElement | null;
54
+ /** With `listChrome`: the `footer`, 16dp under the last row. `null` without one. */
55
+ ListFooterComponent?: React.ReactElement | null;
56
+ /** With `listChrome`: the block's 16dp inset around the rows, header and footer. */
57
+ contentContainerStyle?: ViewStyle;
58
+ /** With `stickyHeader`: reports the list's offset so the pinned header fills once rows scroll under it. */
59
+ onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
60
+ scrollEventThrottle?: number;
26
61
  }
27
62
  export interface TradeHistoryListBlockProps {
28
63
  labels: TradeHistoryListLabels;
@@ -34,11 +69,42 @@ export interface TradeHistoryListBlockProps {
34
69
  onBack?: () => void;
35
70
  /** A control on the trailing edge of the header, usually an IconButton. */
36
71
  headerAction?: React.ReactNode;
37
- /** Format of the result. Defaults to signed US dollars at four significant digits: `+$1.412`, `+$17.90`, `-$0.6878`. */
72
+ /** Format of the result. Defaults to signed US dollars at four significant digits: `+$1.412`, `+$17.90`, `-$0.6878`. The provider's `numberFormat` is merged under it. */
38
73
  pnlOptions?: Intl.NumberFormatOptions;
74
+ /** Draws rows of skeletons in place of the trades while the host loads them. */
75
+ loading?: boolean;
76
+ /** Host text that names the skeleton rows for assistive technology: Loading history. Without it they are only marked busy. */
77
+ loadingLabel?: string;
78
+ /** Why the trades could not load, in place of the rows, in the negative colour and announced. */
79
+ error?: string;
80
+ /** Host content under the header, above the rows: a partial-history notice or a mode banner. */
81
+ notice?: React.ReactNode;
82
+ /** Host content under the rows: paging, a spinner for the next page, a note. */
83
+ footer?: React.ReactNode;
84
+ /**
85
+ * Draws the rows through the host's own list, so a long history does not mount every row at once:
86
+ * `renderList={list => <FlatList data={list.trades} {...list} initialNumToRender={10}/>}`. The header, notice and footer stay
87
+ * fixed around the list in the block's inset, and the block fills its parent (`flex: 1`), so place it in a bounded container
88
+ * such as a sheet body, not inside a ScrollView.
89
+ */
90
+ renderList?: (list: TradeHistoryListRender) => React.ReactNode;
91
+ /**
92
+ * With `renderList`: hands the list the header, notice, footer and inset as well (`ListHeaderComponent`, `ListFooterComponent`,
93
+ * `contentContainerStyle`), so they scroll with the rows, a spread FlatList holds the whole screen and a sheet that sizes itself
94
+ * to its content measures the list alone. The block then adds no padding of its own. Spread the whole object.
95
+ */
96
+ listChrome?: boolean;
97
+ /** Keeps the header pinned while the rows scroll, transparent at rest and filled once rows scroll under it. Without `renderList` the block becomes its own scroll view; with it the header stays above the host's list, which reports its offset through `onScroll`. Place it in a bounded container. */
98
+ stickyHeader?: boolean;
99
+ /** Fill behind the pinned header once rows scroll under it. Defaults to the background role; in a sheet pass the sheet's fill. */
100
+ stickyHeaderBackground?: string;
101
+ /** The scroll view used with `stickyHeader` without `renderList`, such as a sheet library's own. */
102
+ scrollComponent?: React.ComponentType<ScrollViewProps>;
39
103
  testID?: string;
40
104
  }
41
105
  /** How a row reads its side: `Short 20×`, or `Short` without leverage. */
42
- export declare const tradeHistorySide: (trade: Pick<TradeHistoryItem, 'side' | 'leverage'>, labels: Pick<TradeHistoryListLabels, 'long' | 'short'>, locale?: string) => string;
43
- /** A history of closed trades as one screen: a header, then one row per trade with the asset, its side and leverage in the direction colour, and the net result in the result colour over its age. */
44
- export declare function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions, testID }: TradeHistoryListBlockProps): React.JSX.Element;
106
+ export declare const tradeHistorySide: (trade: Pick<TradeHistoryItem, 'side' | 'leverage'> & {
107
+ leverageNote?: string;
108
+ }, labels: Pick<TradeHistoryListLabels, 'long' | 'short'>, locale?: string) => string;
109
+ /** A history of closed trades as one screen: a header, then one row per trade with the asset, its side and leverage in the market direction colour, and the net result in the market direction colour over its age. */
110
+ export declare function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions, loading, loadingLabel, error, notice, footer, renderList, listChrome, stickyHeader, stickyHeaderBackground, scrollComponent, testID }: TradeHistoryListBlockProps): React.JSX.Element;
@@ -1,29 +1,64 @@
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
3
  import { formatNumber } from '@bloxwap/hig/contracts';
4
- import { useColors, useFills, useHIG, useMessages } from './provider.js';
4
+ import { useColors, useFills, useHIG, useNumberLocale, usePresentNumber } from './provider.js';
5
5
  import { Text } from './surface.js';
6
- import { IconButton } from './button.js';
7
6
  import { ChevronIcon } from './icons.js';
7
+ import { ScreenHeader } from './screen-header.js';
8
+ import { StickyHeaderLayout, stickyHeaderFill, useStickyHeaderScroll } from './sticky-header.js';
8
9
  import { AnimatedNumberReadout } from './animated-number.js';
9
10
  const pnlFormat = { style: 'currency', currency: 'USD', signDisplay: 'exceptZero', minimumSignificantDigits: 4, maximumSignificantDigits: 4 };
10
11
  /** How a row reads its side: `Short 20×`, or `Short` without leverage. */
11
- export const tradeHistorySide = (trade, labels, locale) => `${trade.side === 'long' ? labels.long : labels.short}${trade.leverage != null ? ` ${formatNumber(trade.leverage, locale)}×` : ''}`;
12
+ export const tradeHistorySide = (trade, labels, locale) => `${trade.side === 'long' ? labels.long : labels.short}${trade.leverage != null ? ` ${formatNumber(trade.leverage, locale)}×` : ''}${trade.leverageNote ? ` ${trade.leverageNote}` : ''}`;
12
13
  const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
13
- const avatar = 40;
14
+ const avatar = 40, skeletons = [0, 1, 2, 3], dot = '·';
15
+ const keyOf = (trade) => trade.id;
16
+ function Gap() { return _jsx(View, { style: { height: 8 } }); }
14
17
  /** Points up; a short turns it over. */
15
18
  function Arrow({ color, down }) { return _jsxs(View, { style: { width: 12, height: 14, alignItems: 'center', transform: down ? [{ rotate: '180deg' }] : undefined }, children: [_jsx(View, { style: { position: 'absolute', top: 1, width: 7, height: 7, borderLeftWidth: 1.75, borderTopWidth: 1.75, borderColor: color, transform: [{ rotate: '45deg' }] } }), _jsx(View, { style: { width: 1.75, height: 14, borderRadius: 1, backgroundColor: color } })] }); }
16
- /** A history of closed trades as one screen: a header, then one row per trade with the asset, its side and leverage in the direction colour, and the net result in the result colour over its age. */
17
- export function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions = pnlFormat, testID }) {
18
- const colors = useColors(), fills = useFills(), t = useMessages(), { direction, locale } = useHIG();
19
+ /** A history of closed trades as one screen: a header, then one row per trade with the asset, its side and leverage in the market direction colour, and the net result in the market direction colour over its age. */
20
+ export function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions = pnlFormat, loading, loadingLabel, error, notice, footer, renderList, listChrome, stickyHeader, stickyHeaderBackground, scrollComponent, testID }) {
21
+ const colors = useColors(), fills = useFills(), { direction } = useHIG(), locale = useNumberLocale(), present = usePresentNumber();
22
+ const listScroll = useStickyHeaderScroll();
19
23
  const shape = { width: avatar, height: avatar, borderRadius: avatar / 2, backgroundColor: fills.raised, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' };
20
24
  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 });
21
- return _jsxs(View, { testID: testID, style: { direction, padding: 16, gap: 16 }, children: [_jsxs(View, { 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: testID ? `${testID}-back` : undefined, onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: testID ? `${testID}-title` : undefined, accessibilityRole: 'header', numberOfLines: 1, style: { flex: 1, textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: colors.text }, children: labels.title }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: headerAction })] }), trades.length === 0 ? _jsx(Text, { testID: testID ? `${testID}-empty` : undefined, style: { paddingVertical: 32, textAlign: 'center', fontSize: 14, lineHeight: 20, color: colors.muted }, children: labels.empty }) :
22
- _jsx(View, { testID: testID ? `${testID}-rows` : undefined, style: { gap: 8 }, children: trades.map(trade => {
23
- const side = colors[trade.side === 'long' ? 'positive' : 'negative'];
24
- const reading = [trade.name, tradeHistorySide(trade, labels, locale), formatNumber(trade.pnl, locale, pnlOptions), trade.time].filter(Boolean).join(', ');
25
- const content = _jsxs(_Fragment, { children: [_jsx(View, { ...hidden, children: typeof trade.icon === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: trade.icon }, style: shape }) : _jsx(View, { style: shape, children: trade.icon ?? _jsx(Text, { accessible: false, maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: trade.name.slice(0, 3) }) }) }), _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: trade.name }), _jsxs(View, { testID: testID ? `${testID}-${trade.id}-side` : undefined, style: { flexDirection: 'row', alignItems: 'center', gap: 4 }, children: [_jsx(Arrow, { color: side, down: trade.side === 'short' }), trade.leverage != null ? _jsx(Text, { style: { fontSize: 14, lineHeight: 20, fontWeight: '600', color: side }, children: `${formatNumber(trade.leverage, locale)}×` }) : null] })] }), _jsxs(View, { ...hidden, style: { alignItems: 'flex-end', justifyContent: 'center' }, children: [_jsx(AnimatedNumberReadout, { value: trade.pnl, options: pnlOptions, tone: trade.pnl == null || trade.pnl === 0 ? 'text' : trade.pnl > 0 ? 'positive' : 'negative', testID: testID ? `${testID}-${trade.id}-pnl` : undefined, style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }), trade.time ? _jsx(Text, { style: { fontSize: 14, lineHeight: 20, color: colors.muted }, children: trade.time }) : null] })] });
26
- return onSelect ? _jsxs(Pressable, { testID: testID ? `${testID}-${trade.id}` : undefined, accessibilityRole: 'button', accessibilityLabel: reading, onPress: () => onSelect(trade), style: ({ pressed }) => row(pressed), children: [content, _jsx(View, { ...hidden, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] }, trade.id)
27
- : _jsx(View, { testID: testID ? `${testID}-${trade.id}` : undefined, accessible: true, accessibilityLabel: reading, style: row(false), children: content }, trade.id);
28
- }) })] });
25
+ const meta = { fontSize: 14, lineHeight: 20, color: colors.muted };
26
+ const draw = (trade) => {
27
+ const side = trade.side === 'long' ? colors.up : colors.down, result = trade.pnlOptions ?? pnlOptions;
28
+ const reading = [trade.name, tradeHistorySide(trade, labels, locale), formatNumber(trade.pnl, locale, present(result)), trade.tag, trade.time].filter(Boolean).join(', ');
29
+ const content = _jsxs(_Fragment, { children: [_jsx(View, { ...hidden, children: typeof trade.icon === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: trade.icon }, style: shape }) : _jsx(View, { style: shape, children: trade.icon ?? _jsx(Text, { accessible: false, maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: trade.symbol ?? trade.name.slice(0, 3) }) }) }), _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: trade.name }), _jsxs(View, { testID: testID ? `${testID}-${trade.id}-side` : undefined, style: { flexDirection: 'row', alignItems: 'center', gap: 4 }, children: [_jsx(Arrow, { color: side, down: trade.side === 'short' }), trade.leverage != null ? _jsx(Text, { style: { fontSize: 14, lineHeight: 20, fontWeight: '600', color: side }, children: `${formatNumber(trade.leverage, locale)}×` }) : null, trade.leverageNote ? _jsx(Text, { testID: testID ? `${testID}-${trade.id}-leverage-note` : undefined, numberOfLines: 1, style: { ...meta, flexShrink: 1 }, children: trade.leverageNote }) : null] })] }), _jsxs(View, { ...hidden, style: trade.tag ? { alignItems: 'flex-end', justifyContent: 'center', flexShrink: 1 } : { alignItems: 'flex-end', justifyContent: 'center' }, children: [_jsx(AnimatedNumberReadout, { value: trade.pnl, options: result, tone: trade.pnl == null || trade.pnl === 0 ? 'text' : trade.pnl > 0 ? 'up' : 'down', testID: testID ? `${testID}-${trade.id}-pnl` : undefined, style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }), trade.tag ? _jsxs(View, { testID: testID ? `${testID}-${trade.id}-meta` : undefined, style: { direction, flexDirection: 'row', alignItems: 'center', gap: 4, flexShrink: 1 }, children: [_jsx(Text, { numberOfLines: 1, style: { ...meta, flexShrink: 1 }, children: trade.tag }), trade.time ? _jsxs(_Fragment, { children: [_jsx(Text, { style: meta, children: dot }), _jsx(Text, { style: meta, children: trade.time })] }) : null] })
30
+ : trade.time ? _jsx(Text, { style: meta, children: trade.time }) : null] })] });
31
+ return onSelect ? _jsxs(Pressable, { testID: testID ? `${testID}-${trade.id}` : undefined, accessibilityRole: 'button', accessibilityLabel: reading, onPress: () => onSelect(trade), style: ({ pressed }) => row(pressed), children: [content, _jsx(View, { ...hidden, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] }, trade.id)
32
+ : _jsx(View, { testID: testID ? `${testID}-${trade.id}` : undefined, accessible: true, accessibilityLabel: reading, style: row(false), children: content }, trade.id);
33
+ };
34
+ const plain = { paddingVertical: 32, textAlign: 'center', fontSize: 14, lineHeight: 20 };
35
+ const body = loading ? _jsx(View, { testID: testID ? `${testID}-loading` : undefined, accessible: !!loadingLabel, accessibilityLabel: loadingLabel, accessibilityState: { busy: true }, style: { gap: 8 }, children: skeletons.map(index => _jsx(View, { style: { minHeight: 56, borderRadius: 28, backgroundColor: fills.raised } }, index)) })
36
+ : error ? _jsx(Text, { testID: testID ? `${testID}-error` : undefined, accessibilityRole: 'alert', accessibilityLiveRegion: 'polite', style: { ...plain, color: colors.negative }, children: error })
37
+ : trades.length === 0 ? (labels.emptyDescription ? _jsxs(View, { testID: testID ? `${testID}-empty` : undefined, accessible: true, accessibilityLabel: `${labels.empty}, ${labels.emptyDescription}`, style: { paddingVertical: 32, gap: 4 }, children: [_jsx(Text, { style: { ...plain, paddingVertical: 0, fontWeight: '600', color: colors.text }, children: labels.empty }), _jsx(Text, { style: { ...plain, paddingVertical: 0, color: colors.muted }, children: labels.emptyDescription })] }) : _jsx(Text, { testID: testID ? `${testID}-empty` : undefined, style: { ...plain, color: colors.muted }, children: labels.empty }))
38
+ : null;
39
+ const header = _jsx(ScreenHeader, { testID: testID, title: labels.title, onBack: onBack, action: headerAction });
40
+ const noticeView = notice != null && notice !== false ? _jsx(View, { testID: testID ? `${testID}-notice` : undefined, style: { gap: 8 }, children: notice }) : null;
41
+ const footerView = footer != null && footer !== false ? _jsx(View, { testID: testID ? `${testID}-footer` : undefined, style: { gap: 8 }, children: footer }) : null;
42
+ let hosted = null;
43
+ if (!body && renderList) {
44
+ const scroll = stickyHeader ? { onScroll: listScroll.onScroll, scrollEventThrottle: listScroll.scrollEventThrottle } : null;
45
+ const base = { trades, renderItem: ({ item }) => draw(item), keyExtractor: keyOf, ItemSeparatorComponent: Gap, ...scroll };
46
+ // listChrome: the list holds the whole screen, with header and notice above the rows, the footer under them, and the block's inset around both.
47
+ const top = stickyHeader ? noticeView : _jsxs(_Fragment, { children: [header, noticeView] });
48
+ const list = renderList(listChrome ? { ...base,
49
+ ListHeaderComponent: stickyHeader && !noticeView ? null : _jsx(View, { style: { direction, gap: 16, paddingBottom: 16 }, children: top }),
50
+ ListFooterComponent: footerView ? _jsx(View, { style: { direction, paddingTop: 16 }, children: footerView }) : null,
51
+ contentContainerStyle: { padding: 16 } } : base);
52
+ hosted = _jsx(View, { testID: testID ? `${testID}-rows` : undefined, style: { flex: 1 }, children: list });
53
+ const pinned = stickyHeader ? _jsx(View, { testID: testID ? `${testID}-sticky-header` : undefined, style: [{ paddingHorizontal: 16, paddingTop: 16 }, stickyHeaderFill(listScroll.scrolled, stickyHeaderBackground ?? colors.background)], children: header }) : null;
54
+ if (listChrome)
55
+ return _jsxs(View, { testID: testID, style: { direction, flex: 1 }, children: [pinned, hosted] });
56
+ // Pinned without listChrome: the header fills over the block's own stack, which keeps the notice, the list and the footer as before.
57
+ if (stickyHeader)
58
+ return _jsxs(View, { testID: testID, style: { direction, flex: 1 }, children: [pinned, _jsxs(View, { style: { padding: 16, gap: 16, flex: 1 }, children: [noticeView, hosted, footerView] })] });
59
+ }
60
+ const rows = body ?? hosted ?? _jsx(View, { testID: testID ? `${testID}-rows` : undefined, style: { gap: 8 }, children: trades.map(draw) });
61
+ if (stickyHeader)
62
+ return _jsxs(StickyHeaderLayout, { testID: testID, headerTestID: testID ? `${testID}-sticky-header` : undefined, header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, bodyStyle: { direction, gap: 16, paddingTop: 16 }, children: [noticeView, rows, footerView] });
63
+ return _jsxs(View, { testID: testID, style: renderList ? { direction, padding: 16, gap: 16, flex: 1 } : { direction, padding: 16, gap: 16 }, children: [header, noticeView, rows, footerView] });
29
64
  }
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { type AddressKind } from './data.js';
3
+ export { VerticalAddress, addressKind, type AddressKind } from './data.js';
4
+ export interface WalletAddressCoreProps {
5
+ address: string;
6
+ kind?: AddressKind;
7
+ /** The QR code, drawn by the host (its own encoder or SVG), laid out in a `size` square. It is read as one image named by the built-in “QR code” label. */
8
+ qr: React.ReactNode;
9
+ /** QR edge in dp; default 196. The address column is exactly as tall. */
10
+ size?: number;
11
+ /** Host clipboard adapter. When set the whole component is one button that copies the address and shows the Tap to copy hint. */
12
+ onCopy?: () => Promise<void> | void;
13
+ /** `false` shows no “Address copied” notice after a copy, for a host that confirms the copy itself. Default `true`. */
14
+ announce?: boolean;
15
+ testID?: string;
16
+ }
17
+ /** @internal The layout both `WalletAddress` entries share. `code` is the QR as drawn, already named for assistive technology. */
18
+ export declare function WalletAddressFrame({ address, kind, code, size, onCopy, announce, testID }: Omit<WalletAddressCoreProps, 'qr'> & {
19
+ code: React.ReactNode;
20
+ }): React.JSX.Element;
21
+ /**
22
+ * `WalletAddress` without the QR encoder: the host passes the code as `qr`, so neither `cuer` nor `react-native-svg` is
23
+ * needed. The address column, the copy button, its hint and the notice are the same as `WalletAddress` from `wallet-address`.
24
+ */
25
+ export declare function WalletAddress({ qr, ...props }: WalletAddressCoreProps): React.JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Pressable, View } from 'react-native';
3
+ import { useColors, useMessages } from './provider.js';
4
+ import { Text } from './surface.js';
5
+ import { Toast, useTransientNotice } from './status.js';
6
+ import { VerticalAddress, addressKind } from './data.js';
7
+ export { VerticalAddress, addressKind } from './data.js';
8
+ const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
9
+ /** Two overlapping rounded squares: copy. */
10
+ function CopyIcon({ color }) { return _jsxs(View, { ...hidden, style: { width: 16, height: 16 }, children: [_jsx(View, { style: { position: 'absolute', left: 0, top: 0, width: 11, height: 11, borderRadius: 3, borderWidth: 1.5, borderColor: color } }), _jsx(View, { style: { position: 'absolute', right: 0, bottom: 0, width: 11, height: 11, borderRadius: 3, borderWidth: 1.5, borderColor: color } })] }); }
11
+ /** @internal The layout both `WalletAddress` entries share. `code` is the QR as drawn, already named for assistive technology. */
12
+ export function WalletAddressFrame({ address, kind, code, size = 196, onCopy, announce = true, testID }) {
13
+ const colors = useColors();
14
+ const t = useMessages();
15
+ const { notice, show, dismiss } = useTransientNotice();
16
+ const layout = kind ?? addressKind(address), rows = Math.max(1, Math.ceil(address.length / (layout === 'ethereum' ? 6 : 4)));
17
+ const body = _jsxs(_Fragment, { children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 16 }, children: [_jsx(View, { style: { width: size, height: size }, children: code }), _jsx(VerticalAddress, { address: address, kind: layout, rowHeight: size / rows, testID: 'wallet-address-column' })] }), onCopy ? _jsxs(View, { ...hidden, style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8, marginTop: 12 }, children: [_jsx(CopyIcon, { color: colors.muted }), _jsx(Text, { style: { color: colors.muted, fontSize: 14, lineHeight: 21 }, children: t.tapToCopy })] }) : null] });
18
+ const copy = () => { if (!onCopy)
19
+ return; Promise.resolve().then(onCopy).then(() => { if (announce)
20
+ show(t.addressCopied); }).catch(() => { }); };
21
+ // The toast sits outside the button so its dismiss control is not nested in another control.
22
+ return _jsxs(View, { testID: testID, style: { alignItems: 'center' }, children: [onCopy ? _jsx(Pressable, { accessibilityRole: 'button', accessibilityLabel: `${t.copyAddress}: ${address}`, testID: 'wallet-address-copy', onPress: copy, style: ({ pressed }) => ({ opacity: pressed ? 0.8 : 1 }), children: body }) : _jsx(View, { children: body }), notice ? _jsx(View, { style: { marginTop: 8 }, children: _jsx(Toast, { notices: [notice], onDismiss: dismiss }) }) : null] });
23
+ }
24
+ /**
25
+ * `WalletAddress` without the QR encoder: the host passes the code as `qr`, so neither `cuer` nor `react-native-svg` is
26
+ * needed. The address column, the copy button, its hint and the notice are the same as `WalletAddress` from `wallet-address`.
27
+ */
28
+ export function WalletAddress({ qr, ...props }) {
29
+ const t = useMessages();
30
+ return _jsx(WalletAddressFrame, { ...props, code: _jsx(View, { accessible: true, accessibilityRole: 'image', accessibilityLabel: t.qrCode, testID: 'wallet-address-qr', style: { width: '100%', height: '100%' }, children: qr }) });
31
+ }
@@ -1,18 +1,14 @@
1
1
  import React from 'react';
2
- import { type AddressKind } from './data.js';
2
+ import { type WalletAddressCoreProps } from './wallet-address-core.js';
3
3
  export { VerticalAddress, addressKind, type AddressKind } from './data.js';
4
- export interface WalletAddressProps {
5
- address: string;
6
- kind?: AddressKind;
4
+ export type { WalletAddressCoreProps } from './wallet-address-core.js';
5
+ export interface WalletAddressProps extends Omit<WalletAddressCoreProps, 'qr'> {
7
6
  /** QR payload when it differs from the address, e.g. an EIP-681 or Solana Pay URI. Defaults to the address. */
8
7
  qrValue?: string;
9
8
  /** Image URL shown in the centre of the QR. */
10
9
  arena?: string;
11
- /** QR edge in dp; default 196. */
12
- size?: number;
13
- /** Host clipboard adapter. When set the whole component is one button that copies the address and shows the Tap to copy hint. */
14
- onCopy?: () => Promise<void> | void;
15
- testID?: string;
10
+ /** The host's own QR drawing in place of the cuer-style code; `qrValue` and `arena` are then unused and nothing is encoded. Without `cuer` installed, import `WalletAddress` from `wallet-address-core` instead. */
11
+ qr?: React.ReactNode;
16
12
  }
17
13
  /** The QR's drawing, in module units: three finder origins, one path of round dots for every other dark module, and the centre square left clear for an arena. */
18
14
  export declare function qrGeometry(grid: readonly (readonly boolean[])[], withArena: boolean): {
@@ -34,4 +30,4 @@ export declare function qrGeometry(grid: readonly (readonly boolean[])[], withAr
34
30
  * With `onCopy` the whole component is one button and a Tap to copy hint sits under it. Needs the optional `cuer` and
35
31
  * `react-native-svg` peers; the encoder comes from `cuer/QrCode`, so React DOM is never loaded.
36
32
  */
37
- export declare function WalletAddress({ address, kind, qrValue, arena, size, onCopy, testID }: WalletAddressProps): React.JSX.Element;
33
+ export declare function WalletAddress({ qrValue, arena, qr, ...props }: WalletAddressProps): React.JSX.Element;
@@ -1,12 +1,10 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React, { useMemo } from 'react';
3
- import { Image, Pressable, View } from 'react-native';
3
+ import { Image } from 'react-native';
4
4
  import Svg, { Path, Rect } from 'react-native-svg';
5
5
  import { create } from 'cuer/QrCode';
6
6
  import { useColors, useMessages } from './provider.js';
7
- import { Text } from './surface.js';
8
- import { Toast, useTransientNotice } from './status.js';
9
- import { VerticalAddress, addressKind } from './data.js';
7
+ import { WalletAddress as WalletAddressCore, WalletAddressFrame } from './wallet-address-core.js';
10
8
  export { VerticalAddress, addressKind } from './data.js';
11
9
  const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
12
10
  /** The QR's drawing, in module units: three finder origins, one path of round dots for every other dark module, and the centre square left clear for an arena. */
@@ -25,26 +23,24 @@ export function qrGeometry(grid, withArena) {
25
23
  }
26
24
  return { edge, finders: [{ x: 0, y: 0 }, { x: far, y: 0 }, { x: 0, y: far }], dots, count, arena: size > 0 ? { origin, size } : null };
27
25
  }
28
- /** Two overlapping rounded squares: copy. */
29
- function CopyIcon({ color }) { return _jsxs(View, { ...hidden, style: { width: 16, height: 16 }, children: [_jsx(View, { style: { position: 'absolute', left: 0, top: 0, width: 11, height: 11, borderRadius: 3, borderWidth: 1.5, borderColor: color } }), _jsx(View, { style: { position: 'absolute', right: 0, bottom: 0, width: 11, height: 11, borderRadius: 3, borderWidth: 1.5, borderColor: color } })] }); }
26
+ /** The cuer-style code: round dots, rounded finder patterns, no tile, and an optional arena image in the centre. */
27
+ function CuerCode({ value, arena, size }) {
28
+ const colors = useColors();
29
+ const t = useMessages();
30
+ const withArena = !!arena;
31
+ const qr = useMemo(() => qrGeometry(create(value, { errorCorrection: withArena ? 'high' : 'medium' }).grid, withArena), [value, withArena]);
32
+ const unit = size / qr.edge;
33
+ return _jsxs(_Fragment, { children: [_jsxs(Svg, { width: size, height: size, viewBox: `0 0 ${qr.edge} ${qr.edge}`, accessible: true, accessibilityRole: 'image', accessibilityLabel: t.qrCode, testID: 'wallet-address-qr', children: [qr.finders.map((finder, index) => _jsxs(React.Fragment, { children: [_jsx(Rect, { x: finder.x + 0.5, y: finder.y + 0.5, width: 6, height: 6, rx: 1.75, fill: 'none', stroke: colors.text, strokeWidth: 1 }), _jsx(Rect, { x: finder.x + 2, y: finder.y + 2, width: 3, height: 3, rx: 0.75, fill: colors.text })] }, index)), _jsx(Path, { d: qr.dots, fill: colors.text })] }), arena && qr.arena ? _jsx(Image, { ...hidden, source: { uri: arena }, testID: 'wallet-address-arena', style: { position: 'absolute', left: (qr.arena.origin + 0.5) * unit, top: (qr.arena.origin + 0.5) * unit, width: (qr.arena.size - 1) * unit, height: (qr.arena.size - 1) * unit, borderRadius: unit } }) : null] });
34
+ }
30
35
  /**
31
36
  * A wallet address to scan or copy: the QR in the cuer style (round dots, rounded finder patterns, no tile) beside the
32
37
  * address as a monospace column exactly as tall as the code. Ethereum (`0x…`) lays out 6 characters a row and Solana 4.
33
38
  * With `onCopy` the whole component is one button and a Tap to copy hint sits under it. Needs the optional `cuer` and
34
39
  * `react-native-svg` peers; the encoder comes from `cuer/QrCode`, so React DOM is never loaded.
35
40
  */
36
- export function WalletAddress({ address, kind, qrValue, arena, size = 196, onCopy, testID }) {
37
- const colors = useColors();
38
- const t = useMessages();
39
- const { notice, show, dismiss } = useTransientNotice();
40
- const layout = kind ?? addressKind(address), rows = Math.max(1, Math.ceil(address.length / (layout === 'ethereum' ? 6 : 4)));
41
- const value = qrValue ?? address, withArena = !!arena;
42
- const qr = useMemo(() => qrGeometry(create(value, { errorCorrection: withArena ? 'high' : 'medium' }).grid, withArena), [value, withArena]);
43
- const unit = size / qr.edge;
44
- const code = _jsxs(View, { style: { width: size, height: size }, children: [_jsxs(Svg, { width: size, height: size, viewBox: `0 0 ${qr.edge} ${qr.edge}`, accessible: true, accessibilityRole: 'image', accessibilityLabel: t.qrCode, testID: 'wallet-address-qr', children: [qr.finders.map((finder, index) => _jsxs(React.Fragment, { children: [_jsx(Rect, { x: finder.x + 0.5, y: finder.y + 0.5, width: 6, height: 6, rx: 1.75, fill: 'none', stroke: colors.text, strokeWidth: 1 }), _jsx(Rect, { x: finder.x + 2, y: finder.y + 2, width: 3, height: 3, rx: 0.75, fill: colors.text })] }, index)), _jsx(Path, { d: qr.dots, fill: colors.text })] }), arena && qr.arena ? _jsx(Image, { ...hidden, source: { uri: arena }, testID: 'wallet-address-arena', style: { position: 'absolute', left: (qr.arena.origin + 0.5) * unit, top: (qr.arena.origin + 0.5) * unit, width: (qr.arena.size - 1) * unit, height: (qr.arena.size - 1) * unit, borderRadius: unit } }) : null] });
45
- const body = _jsxs(_Fragment, { children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 16 }, children: [code, _jsx(VerticalAddress, { address: address, kind: layout, rowHeight: size / rows, testID: 'wallet-address-column' })] }), onCopy ? _jsxs(View, { ...hidden, style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8, marginTop: 12 }, children: [_jsx(CopyIcon, { color: colors.muted }), _jsx(Text, { style: { color: colors.muted, fontSize: 14, lineHeight: 21 }, children: t.tapToCopy })] }) : null] });
46
- const copy = () => { if (!onCopy)
47
- return; Promise.resolve().then(onCopy).then(() => show(t.addressCopied)).catch(() => { }); };
48
- // The toast sits outside the button so its dismiss control is not nested in another control.
49
- return _jsxs(View, { testID: testID, style: { alignItems: 'center' }, children: [onCopy ? _jsx(Pressable, { accessibilityRole: 'button', accessibilityLabel: `${t.copyAddress}: ${address}`, testID: 'wallet-address-copy', onPress: copy, style: ({ pressed }) => ({ opacity: pressed ? 0.8 : 1 }), children: body }) : _jsx(View, { children: body }), notice ? _jsx(View, { style: { marginTop: 8 }, children: _jsx(Toast, { notices: [notice], onDismiss: dismiss }) }) : null] });
41
+ export function WalletAddress({ qrValue, arena, qr, ...props }) {
42
+ // As on web, `null` falls back to the cuer code like a missing `qr`.
43
+ if (qr != null)
44
+ return _jsx(WalletAddressCore, { ...props, qr: qr });
45
+ return _jsx(WalletAddressFrame, { ...props, code: _jsx(CuerCode, { value: qrValue ?? props.address, arena: arena, size: props.size ?? 196 }) });
50
46
  }
@@ -1,6 +1,6 @@
1
1
  # @bloxwap/hig/native-fonts
2
2
 
3
- Version 0.6.0, an entry of `@bloxwap/hig`. Static Bloxwap Sans/Mono (and Korean/Simplified Chinese Sans) TTF faces for React Native and Expo hosts, derived reproducibly from pinned `@bloxwap/font` 0.1.4 by `npm run generate:fonts`.
3
+ Version 0.7.0, an entry of `@bloxwap/hig`. Static Bloxwap Sans/Mono (and Korean/Simplified Chinese Sans) TTF faces for React Native and Expo hosts, derived reproducibly from pinned `@bloxwap/font` 0.1.4 by `npm run generate:fonts`.
4
4
 
5
5
  Web hosts never import this entry: load fonts through `@bloxwap/font` and use `@bloxwap/hig/tokens/css`. Open Graph card renderers (Satori, `next/og`) use the much smaller `@bloxwap/hig/og-fonts` entry instead (#99).
6
6
 
@@ -1,6 +1,6 @@
1
1
  # @bloxwap/hig/og-fonts
2
2
 
3
- Version 0.6.0, an entry of `@bloxwap/hig`. Five static Latin Bloxwap Sans/Mono TTF faces for Open Graph card renderers: Satori, `next/og` `ImageResponse` and `@vercel/og`. Satori reads TTF/OTF but not WOFF2, and `@bloxwap/font` ships only WOFF2.
3
+ Version 0.7.0, an entry of `@bloxwap/hig`. Five static Latin Bloxwap Sans/Mono TTF faces for Open Graph card renderers: Satori, `next/og` `ImageResponse` and `@vercel/og`. Satori reads TTF/OTF but not WOFF2, and `@bloxwap/font` ships only WOFF2.
4
4
 
5
5
  | Face | File | Weight |
6
6
  | --- | --- | --- |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloxwap/hig",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Bloxwap Human Interface Guidelines: tokens, contracts, React and React Native components, chart adapter, feedback and fonts in one package.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -258,6 +258,11 @@
258
258
  "import": "./react/dist/wallet-address.js",
259
259
  "default": "./react/dist/wallet-address.js"
260
260
  },
261
+ "./react/wallet-address-core": {
262
+ "types": "./react/dist/wallet-address-core.d.ts",
263
+ "import": "./react/dist/wallet-address-core.js",
264
+ "default": "./react/dist/wallet-address-core.js"
265
+ },
261
266
  "./react/asset-balance-row": {
262
267
  "types": "./react/dist/asset-balance-row.d.ts",
263
268
  "import": "./react/dist/asset-balance-row.js",
@@ -328,6 +333,11 @@
328
333
  "import": "./react/dist/blocks/profile-block.js",
329
334
  "default": "./react/dist/blocks/profile-block.js"
330
335
  },
336
+ "./react/blocks/screen-header": {
337
+ "types": "./react/dist/blocks/screen-header.d.ts",
338
+ "import": "./react/dist/blocks/screen-header.js",
339
+ "default": "./react/dist/blocks/screen-header.js"
340
+ },
331
341
  "./react/bar-mark": {
332
342
  "types": "./react/dist/bar-mark.d.ts",
333
343
  "import": "./react/dist/bar-mark.js",
@@ -358,6 +368,11 @@
358
368
  "import": "./native/dist/wallet-address.js",
359
369
  "default": "./native/dist/wallet-address.js"
360
370
  },
371
+ "./native/wallet-address-core": {
372
+ "types": "./native/dist/wallet-address-core.d.ts",
373
+ "import": "./native/dist/wallet-address-core.js",
374
+ "default": "./native/dist/wallet-address-core.js"
375
+ },
361
376
  "./native/asset-balance-row": {
362
377
  "types": "./native/dist/asset-balance-row.d.ts",
363
378
  "import": "./native/dist/asset-balance-row.js",
@@ -428,6 +443,11 @@
428
443
  "import": "./native/dist/profile-block.js",
429
444
  "default": "./native/dist/profile-block.js"
430
445
  },
446
+ "./native/screen-header": {
447
+ "types": "./native/dist/screen-header.d.ts",
448
+ "import": "./native/dist/screen-header.js",
449
+ "default": "./native/dist/screen-header.js"
450
+ },
431
451
  "./native/bar-mark": {
432
452
  "types": "./native/dist/bar-mark.d.ts",
433
453
  "import": "./native/dist/bar-mark.js",
package/react/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @bloxwap/hig/react
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/react/provider`. It accepts opaque sRGB hex (`#RGB` or `#RRGGBB`),
@@ -17,4 +17,10 @@ export interface AnimatedNumberTransitionToken extends AnimatedNumberToken {
17
17
  changed: boolean;
18
18
  }
19
19
  export declare function createAnimatedNumberModel(value: number | null | undefined, locale: string, options?: Intl.NumberFormatOptions): AnimatedNumberModel;
20
+ /**
21
+ * A model for host-formatted text. Without `animate` it is the text as one static token. With it, every digit of the text
22
+ * (ASCII, or the locale's own digits) is a place keyed by its position counted from the end, so a host's own number table
23
+ * still moves place by place; everything else stays as written.
24
+ */
25
+ export declare function createFormattedAnimatedNumberModel(text: string, locale: string, animate: boolean): AnimatedNumberModel;
20
26
  export declare function createAnimatedNumberTransitions(previous: AnimatedNumberModel | null, next: AnimatedNumberModel): readonly AnimatedNumberTransitionToken[];
@@ -59,6 +59,39 @@ export function createAnimatedNumberModel(value, locale, options) {
59
59
  }
60
60
  return tokens.some(token => token.digit) ? { reading, tokens, animatable: true } : staticModel(reading);
61
61
  }
62
+ /**
63
+ * A model for host-formatted text. Without `animate` it is the text as one static token. With it, every digit of the text
64
+ * (ASCII, or the locale's own digits) is a place keyed by its position counted from the end, so a host's own number table
65
+ * still moves place by place; everything else stays as written.
66
+ */
67
+ export function createFormattedAnimatedNumberModel(text, locale, animate) {
68
+ if (!animate)
69
+ return staticModel(text);
70
+ const ascii = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
71
+ let local = null;
72
+ try {
73
+ local = digitsFor(new Intl.NumberFormat(locale));
74
+ }
75
+ catch {
76
+ local = null;
77
+ }
78
+ const characters = Array.from(text), values = characters.map(character => { const own = ascii.indexOf(character); return own >= 0 ? own : local ? local.indexOf(character) : -1; });
79
+ const count = values.filter(value => value >= 0).length;
80
+ if (!count)
81
+ return staticModel(text);
82
+ const tokens = [];
83
+ let run = '', seen = 0;
84
+ const flush = () => { if (run) {
85
+ tokens.push({ key: `literal:${tokens.length}`, text: run, digit: false });
86
+ run = '';
87
+ } };
88
+ characters.forEach((character, index) => { const value = values[index]; if (value < 0) {
89
+ run += character;
90
+ return;
91
+ } flush(); const place = count - ++seen; tokens.push({ key: `digit:number:${place}`, text: character, digit: true, value, place, section: 'number' }); });
92
+ flush();
93
+ return { reading: text, tokens, animatable: true };
94
+ }
62
95
  export function createAnimatedNumberTransitions(previous, next) {
63
96
  if (!previous?.animatable || !next.animatable)
64
97
  return next.tokens.map(token => ({ ...token, changed: false }));
@@ -4,5 +4,9 @@ export type AnimatedNumberTrend = -1 | 0 | 1 | ((oldValue: number, newValue: num
4
4
  export interface AnimatedNumberProps extends NumberProps {
5
5
  duration?: number;
6
6
  trend?: AnimatedNumberTrend;
7
+ /** Host-formatted text for a finite `value`, drawn in place of the Intl reading and read the same way, for a host whose number table the browser's Intl does not match. Never parse it back. Empty text falls back to Intl. Unknown values still read as the dash. */
8
+ formattedValue?: string;
9
+ /** With `formattedValue`, moves the host's text place by place: each digit rolls in place, counted from the end, and the rest stays as written. Without it `formattedValue` is drawn static. */
10
+ animateFormatted?: boolean;
7
11
  }
8
- export declare function AnimatedNumberReadout({ duration, trend, ...props }: AnimatedNumberProps): React.JSX.Element;
12
+ export declare function AnimatedNumberReadout({ duration, trend, options: requested, formattedValue, animateFormatted, ...rest }: AnimatedNumberProps): React.JSX.Element;