@bloxwap/hig 0.5.1 → 0.6.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 (142) hide show
  1. package/README.md +1 -1
  2. package/chart/README.md +1 -1
  3. package/contracts/README.md +1 -1
  4. package/contracts/dist/messages.d.ts +31 -4
  5. package/contracts/dist/messages.js +11 -2
  6. package/feedback/README.md +1 -1
  7. package/native/README.md +1 -1
  8. package/native/dist/account-block.d.ts +46 -0
  9. package/native/dist/account-block.js +28 -0
  10. package/native/dist/asset-balance-row.d.ts +20 -0
  11. package/native/dist/asset-balance-row.js +21 -0
  12. package/native/dist/bar-mark.d.ts +45 -0
  13. package/native/dist/bar-mark.js +34 -0
  14. package/native/dist/bar-pnl.d.ts +50 -0
  15. package/native/dist/bar-pnl.js +59 -0
  16. package/native/dist/blocks.d.ts +44 -0
  17. package/native/dist/{recipes.js → blocks.js} +20 -9
  18. package/native/dist/field.d.ts +0 -1
  19. package/native/dist/field.js +0 -1
  20. package/native/dist/icons.d.ts +8 -0
  21. package/native/dist/icons.js +4 -0
  22. package/native/dist/language-block.d.ts +31 -0
  23. package/native/dist/language-block.js +30 -0
  24. package/native/dist/list-group.d.ts +26 -0
  25. package/native/dist/list-group.js +27 -0
  26. package/native/dist/manage-position-block.d.ts +69 -0
  27. package/native/dist/manage-position-block.js +57 -0
  28. package/native/dist/notifications-block.d.ts +25 -0
  29. package/native/dist/notifications-block.js +14 -0
  30. package/native/dist/pickers.d.ts +13 -5
  31. package/native/dist/pickers.js +10 -6
  32. package/native/dist/position-block.d.ts +51 -0
  33. package/native/dist/position-block.js +21 -0
  34. package/native/dist/profile-block.d.ts +42 -0
  35. package/native/dist/profile-block.js +28 -0
  36. package/native/dist/reward-block.d.ts +83 -0
  37. package/native/dist/reward-block.js +35 -0
  38. package/native/dist/setting-header.d.ts +8 -0
  39. package/native/dist/setting-header.js +11 -0
  40. package/native/dist/setting-switch.d.ts +18 -0
  41. package/native/dist/setting-switch.js +17 -0
  42. package/native/dist/signals-block.d.ts +37 -0
  43. package/native/dist/signals-block.js +16 -0
  44. package/native/dist/sound-haptics-block.d.ts +39 -0
  45. package/native/dist/sound-haptics-block.js +21 -0
  46. package/native/dist/{swap-panel.d.ts → swap-panel-block.d.ts} +28 -9
  47. package/native/dist/{swap-panel.js → swap-panel-block.js} +24 -14
  48. package/native/dist/swap-parts.d.ts +14 -3
  49. package/native/dist/swap-parts.js +16 -1
  50. package/native/dist/swap-shared.d.ts +18 -6
  51. package/native/dist/swap-shared.js +3 -2
  52. package/native/dist/swap-sheet.d.ts +4 -4
  53. package/native/dist/swap-sheet.js +4 -4
  54. package/native/dist/swap-views.d.ts +1 -1
  55. package/native/dist/swap-views.js +11 -8
  56. package/native/dist/target-block.d.ts +83 -0
  57. package/native/dist/target-block.js +61 -0
  58. package/native/dist/token-action-block.d.ts +39 -0
  59. package/native/dist/token-action-block.js +20 -0
  60. package/native/dist/trade-history-detail-block.d.ts +59 -0
  61. package/native/dist/trade-history-detail-block.js +38 -0
  62. package/native/dist/trade-history-list-block.d.ts +44 -0
  63. package/native/dist/trade-history-list-block.js +29 -0
  64. package/native-fonts/README.md +1 -1
  65. package/og-fonts/README.md +1 -1
  66. package/package.json +246 -41
  67. package/react/README.md +1 -1
  68. package/react/dist/asset-balance-row.d.ts +19 -0
  69. package/react/dist/asset-balance-row.js +10 -0
  70. package/react/dist/bar-mark.d.ts +35 -0
  71. package/react/dist/bar-mark.js +21 -0
  72. package/react/dist/bar-pnl.d.ts +49 -0
  73. package/react/dist/bar-pnl.js +45 -0
  74. package/react/dist/blocks/account-block.d.ts +46 -0
  75. package/react/dist/blocks/account-block.js +27 -0
  76. package/react/dist/blocks/language-block.d.ts +32 -0
  77. package/react/dist/blocks/language-block.js +51 -0
  78. package/react/dist/blocks/manage-position-block.d.ts +67 -0
  79. package/react/dist/blocks/manage-position-block.js +28 -0
  80. package/react/dist/blocks/notifications-block.d.ts +23 -0
  81. package/react/dist/blocks/notifications-block.js +8 -0
  82. package/react/dist/{recipes → blocks}/pickers.d.ts +12 -4
  83. package/react/dist/{recipes → blocks}/pickers.js +9 -6
  84. package/react/dist/blocks/position-block.d.ts +49 -0
  85. package/react/dist/blocks/position-block.js +14 -0
  86. package/react/dist/blocks/profile-block.d.ts +48 -0
  87. package/react/dist/blocks/profile-block.js +15 -0
  88. package/react/dist/blocks/reward-block.d.ts +81 -0
  89. package/react/dist/blocks/reward-block.js +24 -0
  90. package/react/dist/blocks/screen-header.d.ts +9 -0
  91. package/react/dist/blocks/screen-header.js +12 -0
  92. package/react/dist/blocks/setting-switch.d.ts +10 -0
  93. package/react/dist/blocks/setting-switch.js +8 -0
  94. package/react/dist/blocks/signals-block.d.ts +35 -0
  95. package/react/dist/blocks/signals-block.js +15 -0
  96. package/react/dist/blocks/sound-haptics-block.d.ts +37 -0
  97. package/react/dist/blocks/sound-haptics-block.js +18 -0
  98. package/react/dist/{recipes → blocks}/swap/picker.d.ts +1 -1
  99. package/react/dist/{recipes → blocks}/swap/picker.js +4 -4
  100. package/react/dist/{recipes → blocks}/swap/settings.js +5 -7
  101. package/react/dist/{recipes → blocks}/swap/shared.d.ts +44 -6
  102. package/react/dist/{recipes → blocks}/swap/shared.js +25 -5
  103. package/react/dist/{recipes/swap-panel.d.ts → blocks/swap-panel-block.d.ts} +29 -9
  104. package/react/dist/{recipes/swap-panel.js → blocks/swap-panel-block.js} +22 -14
  105. package/react/dist/{recipes → blocks}/swap-sheet.d.ts +4 -4
  106. package/react/dist/{recipes → blocks}/swap-sheet.js +4 -4
  107. package/react/dist/blocks/target-block.d.ts +81 -0
  108. package/react/dist/blocks/target-block.js +65 -0
  109. package/react/dist/blocks/token-action-block.d.ts +37 -0
  110. package/react/dist/blocks/token-action-block.js +18 -0
  111. package/react/dist/{recipes → blocks}/trade-entry.js +2 -2
  112. package/react/dist/blocks/trade-history-detail-block.d.ts +58 -0
  113. package/react/dist/blocks/trade-history-detail-block.js +16 -0
  114. package/react/dist/blocks/trade-history-list-block.d.ts +43 -0
  115. package/react/dist/blocks/trade-history-list-block.js +21 -0
  116. package/react/dist/blocks.d.ts +20 -0
  117. package/react/dist/blocks.js +21 -0
  118. package/react/dist/field.d.ts +0 -2
  119. package/react/dist/field.js +0 -2
  120. package/react/dist/list-group.d.ts +26 -0
  121. package/react/dist/list-group.js +20 -0
  122. package/react/dist/styles.css +275 -8
  123. package/tokens/README.md +1 -1
  124. package/native/dist/recipes.d.ts +0 -45
  125. package/react/dist/recipes/activity-list.d.ts +0 -8
  126. package/react/dist/recipes/activity-list.js +0 -6
  127. package/react/dist/recipes/balance-card.d.ts +0 -6
  128. package/react/dist/recipes/balance-card.js +0 -5
  129. package/react/dist/recipes/code-window.d.ts +0 -4
  130. package/react/dist/recipes/code-window.js +0 -4
  131. package/react/dist/recipes.d.ts +0 -10
  132. package/react/dist/recipes.js +0 -11
  133. /package/react/dist/{recipes → blocks}/install-command.d.ts +0 -0
  134. /package/react/dist/{recipes → blocks}/install-command.js +0 -0
  135. /package/react/dist/{recipes → blocks}/market-row.d.ts +0 -0
  136. /package/react/dist/{recipes → blocks}/market-row.js +0 -0
  137. /package/react/dist/{recipes → blocks}/marketing-hero.d.ts +0 -0
  138. /package/react/dist/{recipes → blocks}/marketing-hero.js +0 -0
  139. /package/react/dist/{recipes → blocks}/swap/amount-card.d.ts +0 -0
  140. /package/react/dist/{recipes → blocks}/swap/amount-card.js +0 -0
  141. /package/react/dist/{recipes → blocks}/swap/settings.d.ts +0 -0
  142. /package/react/dist/{recipes → blocks}/trade-entry.d.ts +0 -0
@@ -6,9 +6,17 @@ export declare function SearchIcon({ color }: {
6
6
  export declare function ChevronIcon({ color }: {
7
7
  color: string;
8
8
  }): React.JSX.Element;
9
+ /** A QR glyph: three finder squares and two cells. */
10
+ export declare function QrIcon({ color }: {
11
+ color: string;
12
+ }): React.JSX.Element;
9
13
  export declare function CloseIcon({ color }: {
10
14
  color: string;
11
15
  }): React.JSX.Element;
16
+ /** A pencil: a slanted barrel over the line it writes on. */
17
+ export declare function EditIcon({ color }: {
18
+ color: string;
19
+ }): React.JSX.Element;
12
20
  export type SeverityIconKind = 'info' | 'success' | 'warning' | 'error';
13
21
  /** Shape as well as colour tells the severities apart: warning is a diamond, the others a circle with their own mark. */
14
22
  export declare function SeverityIcon({ kind, color }: {
@@ -8,7 +8,11 @@ function Bar({ length, color, angle }) { return _jsx(View, { style: { position:
8
8
  export function SearchIcon({ color }) { return _jsxs(View, { ...hidden, style: { width: 18, height: 18 }, children: [_jsx(View, { style: { width: 13, height: 13, borderRadius: 7, borderWidth: stroke, borderColor: color } }), _jsx(View, { style: { position: 'absolute', right: 1, bottom: 3, width: 6, height: stroke, borderRadius: stroke, backgroundColor: color, transform: [{ rotate: '45deg' }] } })] }); }
9
9
  /** Points down; the caller rotates it. */
10
10
  export function ChevronIcon({ color }) { return _jsx(View, { ...hidden, style: { width: 20, height: 20, ...centre }, children: _jsx(View, { style: { width: 9, height: 9, borderRightWidth: stroke, borderBottomWidth: stroke, borderColor: color, transform: [{ translateY: -2 }, { rotate: '45deg' }] } }) }); }
11
+ /** A QR glyph: three finder squares and two cells. */
12
+ export function QrIcon({ color }) { const finder = (position) => _jsx(View, { style: { position: 'absolute', width: 7, height: 7, borderRadius: 1.5, borderWidth: stroke, borderColor: color, ...position } }); const cell = (position) => _jsx(View, { style: { position: 'absolute', width: 3, height: 3, backgroundColor: color, ...position } }); return _jsxs(View, { ...hidden, style: { width: 20, height: 20 }, children: [finder({ left: 2, top: 2 }), finder({ right: 2, top: 2 }), finder({ left: 2, bottom: 2 }), cell({ right: 6, bottom: 6 }), cell({ right: 2, bottom: 2 })] }); }
11
13
  export function CloseIcon({ color }) { return _jsxs(View, { ...hidden, style: { width: 20, height: 20, ...centre }, children: [_jsx(Bar, { length: 14, color: color, angle: '45deg' }), _jsx(Bar, { length: 14, color: color, angle: '-45deg' })] }); }
14
+ /** A pencil: a slanted barrel over the line it writes on. */
15
+ export function EditIcon({ color }) { return _jsxs(View, { ...hidden, style: { width: 20, height: 20, ...centre }, children: [_jsx(View, { style: { position: 'absolute', top: 6, width: 13, height: 5, borderRadius: 1.5, borderWidth: stroke, borderColor: color, transform: [{ rotate: '-45deg' }] } }), _jsx(View, { style: { position: 'absolute', bottom: 2, start: 3, width: 14, height: stroke, borderRadius: stroke, backgroundColor: color } })] }); }
12
16
  /** Shape as well as colour tells the severities apart: warning is a diamond, the others a circle with their own mark. */
13
17
  export function SeverityIcon({ kind, color }) {
14
18
  const mark = kind === 'success' ? _jsx(View, { style: { width: 9, height: 5, borderLeftWidth: stroke, borderBottomWidth: stroke, borderColor: color, transform: [{ translateY: -1 }, { rotate: '-45deg' }] } })
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ /** One language the host offers. */
3
+ export interface LanguageOption {
4
+ /** Stable id the host switches on, usually a BCP 47 tag such as `pt-BR`. */
5
+ code: string;
6
+ /** The language in its own words: `Français`. */
7
+ name: string;
8
+ /** The language in the reader's words, shown under the name: `French`. Omit it where it would repeat the name. */
9
+ description?: string;
10
+ /** Round artwork, usually a flag: an image URL or a host element. Without it the row shows the first letters of the code. */
11
+ flag?: string | React.ReactElement;
12
+ }
13
+ export interface LanguageBlockProps {
14
+ /** Heading. Defaults to the built-in “Language”. */
15
+ title?: string;
16
+ /** Shows Back on the leading edge of the header. */
17
+ onBack?: () => void;
18
+ /** A control on the trailing edge of the header, usually an IconButton that closes the sheet. */
19
+ headerAction?: React.ReactNode;
20
+ languages: readonly LanguageOption[];
21
+ /** `code` of the language in use. */
22
+ value?: string | null;
23
+ onSelect: (language: LanguageOption) => void;
24
+ /** Set false to leave out the search field, for a short list. Default `true`. */
25
+ search?: boolean;
26
+ testID?: string;
27
+ }
28
+ /** The languages whose name, description or code contains the query, ignoring case and accents. An empty query keeps every language, in the host's order. */
29
+ export declare function filterLanguages(languages: readonly LanguageOption[], query: string): LanguageOption[];
30
+ /** Choose the app's language as one screen: a header, a search field, then each language as a row with its flag, its own name over the reader's name for it, and a check on the one in use. */
31
+ export declare function LanguageBlock({ title, onBack, headerAction, languages, value, onSelect, search, testID }: LanguageBlockProps): React.JSX.Element;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useState } from 'react';
3
+ import { Image, Pressable, View } from 'react-native';
4
+ import { useColors, useFills, useHIG, useMessages } from './provider.js';
5
+ import { Text } from './surface.js';
6
+ import { IconButton } from './button.js';
7
+ import { SearchInput } from './field.js';
8
+ import { ChevronIcon } from './icons.js';
9
+ const fold = (text) => text.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase();
10
+ /** The languages whose name, description or code contains the query, ignoring case and accents. An empty query keeps every language, in the host's order. */
11
+ export function filterLanguages(languages, query) {
12
+ const needle = fold(query.trim());
13
+ return needle === '' ? [...languages] : languages.filter(language => fold(`${language.name} ${language.description ?? ''} ${language.code}`).includes(needle));
14
+ }
15
+ const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
16
+ const avatar = 40;
17
+ /** Choose the app's language as one screen: a header, a search field, then each language as a row with its flag, its own name over the reader's name for it, and a check on the one in use. */
18
+ export function LanguageBlock({ title, onBack, headerAction, languages, value = null, onSelect, search = true, testID }) {
19
+ const colors = useColors(), fills = useFills(), t = useMessages(), { direction } = useHIG();
20
+ const [query, setQuery] = useState('');
21
+ const rows = useMemo(() => filterLanguages(languages, query), [languages, query]);
22
+ const heading = title ?? t.language;
23
+ const shape = { width: avatar, height: avatar, borderRadius: avatar / 2, backgroundColor: fills.raised, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' };
24
+ const row = (pressed) => ({ flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 56, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 28, backgroundColor: pressed ? fills.well : 'transparent' });
25
+ 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: heading }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: headerAction })] }), search ? _jsx(SearchInput, { testID: testID ? `${testID}-search` : undefined, accessibilityLabel: t.searchLanguages, placeholder: t.searchLanguages, value: query, onChangeText: setQuery, returnKeyType: 'search', autoCapitalize: 'none', autoCorrect: false, spellCheck: false }) : null, rows.length === 0 ? _jsx(Text, { testID: testID ? `${testID}-empty` : undefined, accessibilityLiveRegion: 'polite', style: { paddingVertical: 32, textAlign: 'center', fontSize: 14, lineHeight: 20, color: colors.muted }, children: t.noResults }) :
26
+ _jsx(View, { testID: testID ? `${testID}-list` : undefined, accessibilityRole: 'radiogroup', accessibilityLabel: heading, style: { gap: 4 }, children: rows.map(language => {
27
+ const selected = language.code === value;
28
+ return _jsxs(Pressable, { testID: testID ? `${testID}-${language.code}` : undefined, accessibilityRole: 'radio', accessibilityState: { checked: selected }, accessibilityLabel: [language.name, language.description].filter(Boolean).join(', '), accessibilityLanguage: language.code, onPress: () => onSelect(language), style: ({ pressed }) => row(pressed), children: [_jsx(View, { ...hidden, children: typeof language.flag === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: language.flag }, style: shape }) : _jsx(View, { style: shape, children: language.flag ?? _jsx(Text, { accessible: false, maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: language.code.slice(0, 2).toUpperCase() }) }) }), _jsxs(View, { ...hidden, style: { flex: 1, flexShrink: 1, minWidth: 0 }, children: [_jsx(Text, { style: { fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.text }, children: language.name }), language.description ? _jsx(Text, { style: { fontSize: 14, lineHeight: 20, color: colors.muted }, children: language.description }) : 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: colors.text, transform: [{ translateY: -1 }, { rotate: '45deg' }] } }) }) : null] }, language.code);
29
+ }) })] });
30
+ }
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ export interface ListGroupProps {
3
+ /** Heading above the group, such as “Settings”. Omit it for an untitled group. */
4
+ title?: string;
5
+ /** `ListRow` elements. */
6
+ children?: React.ReactNode;
7
+ testID?: string;
8
+ }
9
+ /** A grouped list for menus and settings: an optional heading over rows that share one rounded container. */
10
+ export declare function ListGroup({ title, children, testID }: ListGroupProps): React.JSX.Element;
11
+ export interface ListRowProps {
12
+ label: string;
13
+ /** Artwork before the label, such as an icon. Decorative: the label names the row. */
14
+ leading?: React.ReactNode;
15
+ /** Short text on the trailing edge, such as `Off`, `English` or a balance. A string is drawn muted and read with the label. */
16
+ value?: React.ReactNode;
17
+ /** Anything richer on the trailing edge: icons, a Badge, or a control such as a Switch. */
18
+ trailing?: React.ReactNode;
19
+ /** Makes the whole row a button, usually one that opens another view, and shows the disclosure chevron. */
20
+ onSelect?: () => void;
21
+ /** Dims the row and blocks `onSelect`. */
22
+ disabled?: boolean;
23
+ testID?: string;
24
+ }
25
+ /** One row of a ListGroup: the label leads; a value, icons, a badge or a control trail. With `onSelect` the whole row is one button and shows a disclosure chevron; without it the row is static, so a control in `trailing` is its only target. */
26
+ export declare function ListRow({ label, leading, value, trailing, onSelect, disabled, testID }: ListRowProps): React.JSX.Element;
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Pressable, View } from 'react-native';
3
+ import { useColors, useFills, useHIG } from './provider.js';
4
+ import { Text } from './surface.js';
5
+ import { ChevronIcon } from './icons.js';
6
+ /** A grouped list for menus and settings: an optional heading over rows that share one rounded container. */
7
+ export function ListGroup({ title, children, testID }) {
8
+ const colors = useColors(), { direction } = useHIG();
9
+ return _jsxs(View, { testID: testID, style: { direction, gap: 8, minWidth: 0 }, children: [title ? _jsx(Text, { accessibilityRole: 'header', testID: testID ? `${testID}-title` : undefined, style: { paddingHorizontal: 4, color: colors.muted, fontSize: 14, lineHeight: 20, fontWeight: '500' }, children: title }) : null, _jsx(View, { testID: testID ? `${testID}-rows` : undefined, style: { gap: 2, borderRadius: 20, overflow: 'hidden' }, children: children })] });
10
+ }
11
+ const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
12
+ /** One row of a ListGroup: the label leads; a value, icons, a badge or a control trail. With `onSelect` the whole row is one button and shows a disclosure chevron; without it the row is static, so a control in `trailing` is its only target. */
13
+ export function ListRow({ label, leading, value, trailing, onSelect, disabled, testID }) {
14
+ const colors = useColors(), fills = useFills(), { direction } = useHIG();
15
+ const row = (pressed) => ({ flexDirection: 'row', alignItems: 'flex-start', gap: 12, minHeight: 56, paddingVertical: 8, paddingHorizontal: 20, backgroundColor: pressed ? fills.raised : fills.well, opacity: disabled ? 0.5 : 1 });
16
+ const text = typeof value === 'string' || typeof value === 'number';
17
+ const reading = [label, text ? String(value) : null].filter(Boolean).join(', ');
18
+ // Everything aligns to the first line of the label, so a trailing switch stays at the top when the label wraps.
19
+ const first = { minHeight: 40, justifyContent: 'center' };
20
+ const lead = leading == null ? null : _jsx(View, { ...hidden, style: first, children: leading });
21
+ const name = _jsx(Text, { ...(onSelect ? hidden : {}), style: { flex: 1, flexShrink: 1, minWidth: 0, paddingVertical: 8, fontSize: 16, lineHeight: 24, color: colors.text }, children: label });
22
+ const amount = value == null || value === false ? null : text ? _jsx(Text, { ...(onSelect ? hidden : {}), numberOfLines: 1, style: { flexShrink: 1, maxWidth: '50%', paddingVertical: 8, fontSize: 16, lineHeight: 24, color: colors.muted, textAlign: 'right' }, children: value }) : _jsx(View, { style: first, children: value });
23
+ const extra = trailing == null ? null : _jsx(View, { pointerEvents: onSelect ? 'none' : 'auto', ...(onSelect ? hidden : {}), style: { flexDirection: 'row', alignItems: 'center', gap: 8, minHeight: 40 }, children: trailing });
24
+ if (!onSelect)
25
+ return _jsxs(View, { testID: testID, style: row(false), children: [lead, name, amount, extra] });
26
+ return _jsxs(Pressable, { testID: testID, accessibilityRole: 'button', accessibilityLabel: reading, accessibilityState: { disabled: !!disabled }, disabled: disabled, onPress: onSelect, style: ({ pressed }) => row(pressed), children: [lead, name, amount, extra, _jsx(View, { ...hidden, style: first, children: _jsx(View, { testID: testID ? `${testID}-chevron` : undefined, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) }) })] });
27
+ }
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import type { AssetArtwork } from './asset-balance-row.js';
3
+ export type { AssetArtwork } from './asset-balance-row.js';
4
+ /** Every trading word of the block. HIG's built-in strings hold no trading terms, so the host supplies them, translated. */
5
+ export interface ManagePositionBlockLabels {
6
+ title: string;
7
+ margin: string;
8
+ notional: string;
9
+ liquidation: string;
10
+ /** `99.8% to liquidation`: receives the formatted percent. */
11
+ toLiquidation: (percent: string) => string;
12
+ mark: string;
13
+ entry: string;
14
+ /** Accessible words for the direction arrow. */
15
+ long: string;
16
+ short: string;
17
+ }
18
+ export interface ManagePositionBlockAction {
19
+ id: string;
20
+ label: string;
21
+ onSelect: () => void;
22
+ disabled?: boolean;
23
+ }
24
+ export interface ManagePositionBlockSummary {
25
+ name: string;
26
+ icon?: AssetArtwork;
27
+ /** 40 reads `40×`. */
28
+ leverage?: number;
29
+ /** Size in asset units. */
30
+ size?: number | null;
31
+ /** Profit and loss in dollars. */
32
+ pnl?: number | null;
33
+ /** Profit and loss as a fraction: -0.0025 reads -0.25%. */
34
+ pnlPercent?: number | null;
35
+ }
36
+ export interface ManagePositionBlockProps {
37
+ labels: ManagePositionBlockLabels;
38
+ /** Margin mode, the title of the first card: Demo, Cross, Isolated. Without it the card is titled with the margin label. */
39
+ mode?: string;
40
+ side: 'long' | 'short';
41
+ entry: number;
42
+ mark?: number | null;
43
+ liquidation?: number | null;
44
+ margin: number;
45
+ notional: number;
46
+ /** Format of the three prices, such as another currency. They are drawn compact: no extra zeros. */
47
+ priceOptions?: Intl.NumberFormatOptions;
48
+ actions: readonly ManagePositionBlockAction[];
49
+ position?: ManagePositionBlockSummary;
50
+ /** Shows Back on the leading edge of the header. */
51
+ onBack?: () => void;
52
+ /** A control on the trailing edge of the header, usually an IconButton. */
53
+ headerAction?: React.ReactNode;
54
+ testID?: string;
55
+ }
56
+ /** Distance left before liquidation. `total` is the span from entry to liquidation, `buffer` how much of it remains between mark and liquidation (the whole span while in profit), `drawdown` the rest, and `share` the buffer as a fraction of the span. Unknown mark or liquidation, or a liquidation on the wrong side of entry, gives zeros and a `null` share. */
57
+ export declare function positionCorridor({ side, entry, mark, liquidation }: {
58
+ side: 'long' | 'short';
59
+ entry: number;
60
+ mark?: number | null;
61
+ liquidation?: number | null;
62
+ }): {
63
+ total: number;
64
+ buffer: number;
65
+ drawdown: number;
66
+ share: number | null;
67
+ };
68
+ /** One open position as a screen: margin and notional under the share left before liquidation, then the liquidation, mark and entry prices as a `BarPnl`, what can be done, and the position itself. Both bars are drawn without a card, because nothing in them can be pressed. */
69
+ export declare function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, onBack, headerAction, testID }: ManagePositionBlockProps): React.JSX.Element;
@@ -0,0 +1,57 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Image, View } from 'react-native';
3
+ import { useColors, useFills, useHIG, useMessages } from './provider.js';
4
+ import { Text } from './surface.js';
5
+ import { IconButton } from './button.js';
6
+ import { ChevronIcon } from './icons.js';
7
+ import { AnimatedNumberReadout } from './animated-number.js';
8
+ import { formatNumberReadout } from './animated-number-model.js';
9
+ import { BarMark } from './bar-mark.js';
10
+ import { BarPnl } from './bar-pnl.js';
11
+ import { ListGroup, ListRow } from './list-group.js';
12
+ const usd = { style: 'currency', currency: 'USD' };
13
+ const pnlUsd = { style: 'currency', currency: 'USD', signDisplay: 'exceptZero', maximumFractionDigits: 4 };
14
+ const pnlShare = { style: 'percent', minimumFractionDigits: 2, maximumFractionDigits: 2, signDisplay: 'exceptZero' };
15
+ const units = { maximumFractionDigits: 6 };
16
+ const tenth = { maximumFractionDigits: 1 };
17
+ const numberMark = '', unknown = '—', times = '×', dot = ' · ', percent = '%', up = '↑', down = '↓';
18
+ const avatar = 40;
19
+ const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
20
+ const known = (value) => value != null && Number.isFinite(value);
21
+ /** Distance left before liquidation. `total` is the span from entry to liquidation, `buffer` how much of it remains between mark and liquidation (the whole span while in profit), `drawdown` the rest, and `share` the buffer as a fraction of the span. Unknown mark or liquidation, or a liquidation on the wrong side of entry, gives zeros and a `null` share. */
22
+ export function positionCorridor({ side, entry, mark, liquidation }) {
23
+ const long = side === 'long', span = known(liquidation) ? long ? entry - liquidation : liquidation - entry : 0;
24
+ if (!known(mark) || !known(liquidation) || !Number.isFinite(span) || span <= 0)
25
+ return { total: 0, buffer: 0, drawdown: 0, share: null };
26
+ const traveled = long ? entry - mark : mark - entry, buffer = Math.min(span, Math.max(0, span - traveled));
27
+ return { total: span, buffer, drawdown: span - buffer, share: buffer / span };
28
+ }
29
+ /** A host sentence with one live number in it. The words keep their translated order, the number updates place by place, and the whole sentence is the accessible reading. Without a value the sentence is plain text. */
30
+ function Sentence({ template, text, value, options, suffix, testID }) {
31
+ const colors = useColors(), { direction } = useHIG();
32
+ const type = { fontSize: 14, lineHeight: 21 }, words = { ...type, color: colors.muted };
33
+ const reading = template(text), parts = template(numberMark).split(numberMark);
34
+ if (value === null || parts.length !== 2)
35
+ return _jsx(Text, { testID: testID, style: { ...words, flexShrink: 1 }, children: reading });
36
+ return _jsxs(View, { accessible: true, accessibilityLabel: reading, testID: testID, style: { direction, flexDirection: 'row', alignItems: 'center', flexShrink: 1 }, children: [parts[0] ? _jsx(Text, { accessible: false, style: words, children: parts[0] }) : null, _jsx(AnimatedNumberReadout, { value: value, options: options, suffix: suffix, tone: 'muted', style: type }), parts[1] ? _jsx(Text, { accessible: false, style: words, children: parts[1] }) : null] });
37
+ }
38
+ /** One open position as a screen: margin and notional under the share left before liquidation, then the liquidation, mark and entry prices as a `BarPnl`, what can be done, and the position itself. Both bars are drawn without a card, because nothing in them can be pressed. */
39
+ export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, onBack, headerAction, testID }) {
40
+ const colors = useColors(), fills = useFills(), t = useMessages(), { direction, locale } = useHIG();
41
+ const read = (value, options) => known(value) ? formatNumberReadout(value, locale, options).text : unknown;
42
+ const corridor = positionCorridor({ side, entry, mark, liquidation }), long = side === 'long';
43
+ const marginBar = [{ id: 'margin', label: labels.margin, value: margin, detail: read(margin, usd), tone: 'info' }, { id: 'notional', label: labels.notional, value: known(notional) ? Math.max(notional - margin, 0) : 0, detail: read(notional, usd), tone: 'positive' }];
44
+ const left = corridor.share === null ? null : corridor.share * 100;
45
+ const shape = { width: avatar, height: avatar, borderRadius: avatar / 2, backgroundColor: fills.raised, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' };
46
+ const row = () => {
47
+ if (!position)
48
+ return null;
49
+ const { name, icon, leverage, size, pnl, pnlPercent } = position;
50
+ 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: name.slice(0, 3) }) });
51
+ const gearing = known(leverage) ? formatNumberReadout(leverage, locale, units).text + times : null, held = size !== undefined ? read(size, units) : null;
52
+ const label = [name, long ? labels.long : labels.short, gearing, held, pnl !== undefined ? read(pnl, pnlUsd) : null, pnlPercent !== undefined ? read(pnlPercent, pnlShare) : null].filter(Boolean).join(', ');
53
+ const meta = { fontSize: 14, lineHeight: 20 };
54
+ return _jsxs(View, { testID: 'manage-position-row', accessible: true, accessibilityLabel: label, style: { flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 56, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 28, backgroundColor: fills.well, marginTop: 16 }, 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 }), _jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', gap: 4 }, children: [_jsx(Text, { testID: 'manage-position-side', style: { ...meta, fontWeight: '600', color: long ? colors.up : colors.down }, children: long ? up : down }), gearing ? _jsx(Text, { testID: 'manage-position-leverage', style: { ...meta, fontWeight: '600', color: long ? colors.up : colors.down }, children: gearing }) : null, gearing && held ? _jsx(Text, { style: { ...meta, color: colors.muted }, children: dot.trim() }) : null, size !== undefined ? _jsx(AnimatedNumberReadout, { value: size, options: units, tone: 'muted', testID: 'manage-position-size', style: meta }) : null] })] }), _jsxs(View, { ...hidden, style: { alignItems: 'flex-end', justifyContent: 'center' }, children: [pnl !== undefined ? _jsx(AnimatedNumberReadout, { value: pnl, options: pnlUsd, tone: known(pnl) && pnl > 0 ? 'up' : known(pnl) && pnl < 0 ? 'down' : 'text', testID: 'manage-position-pnl', style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) : null, pnlPercent !== undefined ? _jsx(AnimatedNumberReadout, { value: pnlPercent, options: pnlShare, tone: 'muted', testID: 'manage-position-pnl-percent', style: meta }) : null] })] });
55
+ };
56
+ return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [_jsxs(View, { testID: 'manage-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: 'manage-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'manage-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, { style: { gap: 20, marginTop: 16, paddingHorizontal: 4 }, children: [_jsx(BarMark, { testID: 'manage-margin', surface: false, title: mode ?? labels.margin, elements: marginBar, description: _jsx(Sentence, { testID: 'manage-to-liquidation', template: labels.toLiquidation, text: left === null ? unknown : formatNumberReadout(left, locale, tenth).text + percent, value: left, options: tenth, suffix: percent }) }), _jsx(BarPnl, { testID: 'manage-liquidation', surface: false, compact: true, side: side, entry: entry, mark: mark, liquidation: liquidation, labels: { liquidation: labels.liquidation, mark: labels.mark, entry: labels.entry }, priceOptions: priceOptions })] }), actions.length > 0 ? _jsx(View, { testID: 'manage-actions', style: { marginTop: 16 }, children: _jsx(ListGroup, { children: actions.map(action => _jsx(ListRow, { testID: `manage-action-${action.id}`, label: action.label, disabled: action.disabled, onSelect: action.onSelect }, action.id)) }) }) : null, row()] });
57
+ }
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ /** One kind of notification. Every word is host text. */
3
+ export interface NotificationsItem {
4
+ id: string;
5
+ label: string;
6
+ description?: string;
7
+ checked: boolean;
8
+ onCheckedChange: (checked: boolean) => void;
9
+ disabled?: boolean;
10
+ /** Why turning it on failed, under the card: Push request timed out. It is announced when it appears. */
11
+ error?: string;
12
+ }
13
+ export interface NotificationsBlockProps {
14
+ /** Heading: Notifications. */
15
+ title: string;
16
+ /** One card each, in order. */
17
+ items: readonly NotificationsItem[];
18
+ /** Shows Back on the leading edge of the header. */
19
+ onBack?: () => void;
20
+ /** A control on the trailing edge of the header, usually an IconButton. */
21
+ headerAction?: React.ReactNode;
22
+ testID?: string;
23
+ }
24
+ /** The notifications the viewer receives, as a screen: each kind is a card with a switch and a line of explanation, and a failure to turn one on reads under its card. */
25
+ export declare function NotificationsBlock({ title, items, onBack, headerAction, testID }: NotificationsBlockProps): React.JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ import { useColors } from './provider.js';
4
+ import { Text } from './surface.js';
5
+ import { SettingCard, SettingHeader, SettingSwitch } from './setting-switch.js';
6
+ /** The notifications the viewer receives, as a screen: each kind is a card with a switch and a line of explanation, and a failure to turn one on reads under its card. */
7
+ export function NotificationsBlock({ title, items, onBack, headerAction, testID }) {
8
+ const colors = useColors();
9
+ const cards = items.map(item => {
10
+ const id = `notifications-${item.id}`;
11
+ return _jsxs(View, { style: { gap: 8 }, children: [_jsx(SettingCard, { testID: id, children: _jsx(SettingSwitch, { testID: `${id}-switch`, label: item.label, description: item.description, checked: item.checked, disabled: item.disabled, onCheckedChange: item.onCheckedChange }) }), item.error ? _jsx(Text, { testID: `${id}-error`, accessibilityRole: 'alert', accessibilityLiveRegion: 'polite', style: { paddingHorizontal: 20, fontSize: 14, lineHeight: 21, color: colors.negative }, children: item.error }) : null] }, item.id);
12
+ });
13
+ return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [_jsx(SettingHeader, { testID: 'notifications', title: title, onBack: onBack, action: headerAction }), items.length > 0 ? _jsx(View, { testID: 'notifications-items', style: { gap: 8, marginTop: 16 }, children: cards }) : null] });
14
+ }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { type StyleProp, type ViewStyle } from 'react-native';
3
3
  import { type SwapChain, type SwapToken, type SwapWallet } from './swap-shared.js';
4
- export type { SwapChain, SwapToken, SwapWallet } from './swap-shared.js';
4
+ export type { SwapChain, SwapFigure, SwapToken, SwapWallet } from './swap-shared.js';
5
5
  /** The searchable token list both pickers share. */
6
6
  export interface PickerListProps {
7
7
  /** Tokens offered: a wallet's holdings, a whitelist, or a whole catalog. */
@@ -19,7 +19,7 @@ export interface PickerListProps {
19
19
  /** Web only: focuses the search with a hardware pointer. Native never raises the keyboard on mount. */
20
20
  autoFocus?: boolean;
21
21
  }
22
- export interface FromPickerProps extends PickerListProps {
22
+ export interface FromPickerBlockProps extends PickerListProps {
23
23
  /** The connected wallet. Omit for a list with no wallet row at all. */
24
24
  wallet?: SwapWallet;
25
25
  /** Shows Connect wallet while no wallet is connected. */
@@ -36,8 +36,8 @@ export interface FromPickerProps extends PickerListProps {
36
36
  * the tokens it holds (or a whitelist). With no wallet it offers Connect wallet and a Generate address switch above the list.
37
37
  * The host owns the wallet, the token data and the generated address.
38
38
  */
39
- export declare function FromPicker({ wallet, onConnect, onDisconnect, generateAddress, onGenerateAddressChange, style, ...list }: FromPickerProps): React.JSX.Element;
40
- export interface ToPickerProps extends Partial<PickerListProps> {
39
+ export declare function FromPickerBlock({ wallet, onConnect, onDisconnect, generateAddress, onGenerateAddressChange, style, ...list }: FromPickerBlockProps): React.JSX.Element;
40
+ export interface ToPickerBlockProps extends Partial<PickerListProps> {
41
41
  /** The destination address field. Omit `onAddressChange` to hide it. */
42
42
  address?: string;
43
43
  onAddressChange?: (address: string) => void;
@@ -51,4 +51,12 @@ export interface ToPickerProps extends Partial<PickerListProps> {
51
51
  * Where the assets go. On its own it is a destination address field with a scan button. With `tokens` it adds the
52
52
  * searchable token list, with the chain filter or, with `chainFilter={false}`, without it.
53
53
  */
54
- export declare function ToPicker({ address, onAddressChange, addressPlaceholder, onScan, style, tokens, onSelect, ...list }: ToPickerProps): React.JSX.Element;
54
+ export declare function ToPickerBlock({ address, onAddressChange, addressPlaceholder, onScan, style, tokens, onSelect, ...list }: ToPickerBlockProps): React.JSX.Element;
55
+ /** @deprecated Renamed `FromPickerBlock`. The old name keeps working until the next major release. */
56
+ export declare const FromPicker: typeof FromPickerBlock;
57
+ /** @deprecated Renamed `FromPickerBlockProps`. */
58
+ export type FromPickerProps = FromPickerBlockProps;
59
+ /** @deprecated Renamed `ToPickerBlock`. The old name keeps working until the next major release. */
60
+ export declare const ToPicker: typeof ToPickerBlock;
61
+ /** @deprecated Renamed `ToPickerBlockProps`. */
62
+ export type ToPickerProps = ToPickerBlockProps;
@@ -1,21 +1,21 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useContext, useMemo, useState } from 'react';
3
3
  import { FlatList, Pressable, View, useWindowDimensions } from 'react-native';
4
- import { formatNumber } from '@bloxwap/hig/contracts';
5
4
  import { useColors, useFills, useHIG, useMessages } from './provider.js';
6
5
  import { Text } from './surface.js';
7
6
  import { Button, IconButton } from './button.js';
8
7
  import { Input, SearchInput } from './field.js';
9
8
  import { Filter } from './radio-group.js';
9
+ import { AnimatedNumberReadout } from './animated-number.js';
10
10
  import { SwitchRow } from './switch-row.js';
11
11
  import { LeaveIcon, LockIcon, ScanIcon, SwapHostContext, TokenIcon, WalletIcon } from './swap-parts.js';
12
12
  import { addressColor, pickerRows, shortAddress } from './swap-shared.js';
13
13
  /** Chains present in a token list, in first-seen order. */
14
14
  function chainsOf(tokens) { const seen = new Map(); for (const token of tokens)
15
15
  if (!seen.has(token.chainId))
16
- seen.set(token.chainId, { chainId: token.chainId, name: token.chain, icon: token.chainIcon }); return [...seen.values()]; }
16
+ seen.set(token.chainId, { chainId: token.chainId, name: token.chain, icon: typeof token.chainIcon === 'string' ? token.chainIcon : undefined }); return [...seen.values()]; }
17
17
  function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected = null, onSelect, loading, side, title }) {
18
- const { locale, direction } = useHIG();
18
+ const { direction } = useHIG();
19
19
  const colors = useColors();
20
20
  const fills = useFills();
21
21
  const t = useMessages();
@@ -33,7 +33,7 @@ function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected =
33
33
  const empty = _jsx(Text, { accessibilityLiveRegion: 'polite', testID: `swap-empty-${side}`, style: { paddingVertical: 32, textAlign: 'center', fontSize: 14, lineHeight: 21, color: colors.muted }, children: loading ? `${t.loading}…` : t.swapNoTokens });
34
34
  return _jsxs(_Fragment, { children: [_jsx(SearchInput, { accessibilityLabel: t.swapSearchTokens, placeholder: t.swapSearchTokens, testID: `swap-search-${side}`, value: query, onChangeText: setQuery, autoCapitalize: 'none', autoCorrect: false, autoComplete: 'off', spellCheck: false }), chainFilter && options.length > 1 ? _jsx(Filter, { label: t.swapChains, options: chainOptions, value: chain, onValueChange: pickChain }) : null, _jsx(List, { style: { height: Math.max(240, Math.round(window.height * 0.5)) }, data: rows, keyExtractor: token => token.id, keyboardShouldPersistTaps: 'handled', accessibilityLabel: title, testID: `swap-list-${side}`, initialNumToRender: 12, ListEmptyComponent: empty, renderItem: ({ item: token, index }) => {
35
35
  const isSelected = selected?.id === token.id, balance = token.balance ?? 0, price = token.price ?? 0;
36
- return _jsxs(View, { children: [hotCount > 0 && index === 0 ? section(t.swapHot) : null, hotCount > 0 && index === hotCount ? section(t.swapAllTokens) : null, _jsxs(Pressable, { accessibilityRole: 'button', accessibilityState: { selected: isSelected }, testID: `swap-token-${token.id}`, onPress: () => onSelect(token), style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', gap: 12, marginBottom: 4, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 9999, backgroundColor: pressed ? fills.well : 'transparent', opacity: isSelected ? 0.5 : 1 }), children: [_jsx(TokenIcon, { token: token }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: token.name }), _jsxs(Text, { style: { fontSize: 14, lineHeight: 21, color: colors.muted }, children: [token.chain, isSelected ? ` · ${t.swapSelected}` : ''] })] }), balance > 0 ? _jsxs(View, { style: { alignItems: 'flex-end' }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: formatNumber(balance, locale, { maximumFractionDigits: 6 }) }), price > 0 ? _jsx(Text, { style: { fontSize: 14, lineHeight: 21, color: colors.muted }, children: formatNumber(balance * price, locale, { style: 'currency', currency: 'USD' }) }) : null] }) : null] })] });
36
+ return _jsxs(View, { children: [hotCount > 0 && index === 0 ? section(t.swapHot) : null, hotCount > 0 && index === hotCount ? section(t.swapAllTokens) : null, _jsxs(Pressable, { accessibilityRole: 'button', accessibilityState: { selected: isSelected }, testID: `swap-token-${token.id}`, onPress: () => onSelect(token), style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', gap: 12, marginBottom: 4, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 9999, backgroundColor: pressed ? fills.well : 'transparent', opacity: isSelected ? 0.5 : 1 }), children: [_jsx(TokenIcon, { token: token }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: token.name }), _jsxs(Text, { style: { fontSize: 14, lineHeight: 21, color: colors.muted }, children: [token.chain, isSelected ? ` · ${t.swapSelected}` : ''] })] }), balance > 0 ? _jsxs(View, { style: { alignItems: 'flex-end' }, children: [_jsx(AnimatedNumberReadout, { testID: `swap-token-balance-${token.id}`, value: balance, options: { maximumFractionDigits: 6 }, style: { fontWeight: '600', textAlign: 'right' } }), price > 0 ? _jsx(AnimatedNumberReadout, { testID: `swap-token-value-${token.id}`, value: balance * price, options: { style: 'currency', currency: 'USD' }, tone: 'muted', style: { fontSize: 14, lineHeight: 21, textAlign: 'right' } }) : null] }) : null] })] });
37
37
  } })] });
38
38
  }
39
39
  /**
@@ -41,7 +41,7 @@ function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected =
41
41
  * the tokens it holds (or a whitelist). With no wallet it offers Connect wallet and a Generate address switch above the list.
42
42
  * The host owns the wallet, the token data and the generated address.
43
43
  */
44
- export function FromPicker({ wallet, onConnect, onDisconnect, generateAddress = false, onGenerateAddressChange, style, ...list }) {
44
+ export function FromPickerBlock({ wallet, onConnect, onDisconnect, generateAddress = false, onGenerateAddressChange, style, ...list }) {
45
45
  const colors = useColors();
46
46
  const fills = useFills();
47
47
  const t = useMessages();
@@ -53,8 +53,12 @@ export function FromPicker({ wallet, onConnect, onDisconnect, generateAddress =
53
53
  * Where the assets go. On its own it is a destination address field with a scan button. With `tokens` it adds the
54
54
  * searchable token list, with the chain filter or, with `chainFilter={false}`, without it.
55
55
  */
56
- export function ToPicker({ address, onAddressChange, addressPlaceholder, onScan, style, tokens, onSelect, ...list }) {
56
+ export function ToPickerBlock({ address, onAddressChange, addressPlaceholder, onScan, style, tokens, onSelect, ...list }) {
57
57
  const colors = useColors();
58
58
  const t = useMessages();
59
59
  return _jsxs(View, { accessibilityLabel: t.swapTo, testID: 'to-picker', style: [{ gap: 16 }, style], children: [onAddressChange ? _jsxs(View, { testID: 'picker-address-row', style: { flexDirection: 'row', alignItems: 'center', gap: 8 }, children: [_jsx(View, { style: { flex: 1 }, children: _jsx(Input, { accessibilityLabel: t.swapRecipient, placeholder: addressPlaceholder ?? t.swapRecipient, testID: 'picker-address', value: address ?? '', onChangeText: onAddressChange, autoCapitalize: 'none', autoCorrect: false, autoComplete: 'off', spellCheck: false }) }), onScan ? _jsx(IconButton, { intent: 'secondary', label: t.swapScan, testID: 'picker-scan', onPress: onScan, style: { minWidth: 48, minHeight: 48 }, children: _jsx(ScanIcon, { color: colors.text }) }) : null] }) : null, tokens && onSelect ? _jsx(TokenList, { ...list, tokens: tokens, onSelect: onSelect, side: 'to', title: t.swapTo }) : null] });
60
60
  }
61
+ /** @deprecated Renamed `FromPickerBlock`. The old name keeps working until the next major release. */
62
+ export const FromPicker = FromPickerBlock;
63
+ /** @deprecated Renamed `ToPickerBlock`. The old name keeps working until the next major release. */
64
+ export const ToPicker = ToPickerBlock;
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ /** A number the host supplies as a number so it updates place by place: `{value:0.53,options:{style:'currency',currency:'USD'}}`. `null` reads as unknown. */
3
+ export interface PositionBlockFigure {
4
+ value: number | null;
5
+ options?: Intl.NumberFormatOptions;
6
+ prefix?: string;
7
+ suffix?: string;
8
+ }
9
+ /** One line of the summary: Notional, Fee, Liquidation. `value` is host text (`2% of profit`) or a live figure. `tone` colours the value; the default is the text colour. */
10
+ export interface PositionBlockDetail {
11
+ id?: string;
12
+ label: string;
13
+ value: string | PositionBlockFigure;
14
+ tone?: 'positive' | 'negative' | 'muted';
15
+ }
16
+ /** One setting of the position: Size, Leverage, Stop Loss. With `onSelect` the row opens the host's own view and shows a chevron. */
17
+ export interface PositionBlockRow {
18
+ id: string;
19
+ label: string;
20
+ value?: string;
21
+ onSelect?: () => void;
22
+ disabled?: boolean;
23
+ }
24
+ /** The paper trading switch. The host supplies its name, because HIG ships no trading terms. */
25
+ export interface PositionBlockFlag {
26
+ label: string;
27
+ checked: boolean;
28
+ onCheckedChange: (checked: boolean) => void;
29
+ disabled?: boolean;
30
+ }
31
+ export interface PositionBlockProps {
32
+ /** Heading: Position. */
33
+ title: string;
34
+ /** The summary under the header, in order. */
35
+ details: readonly PositionBlockDetail[];
36
+ /** One sentence under the summary, such as the minimum margin. */
37
+ note?: string;
38
+ /** Shows the paper trading switch as a row of its own above the settings. */
39
+ paperTrade?: PositionBlockFlag;
40
+ /** The settings, as groups of rows. Each group is one rounded container. */
41
+ groups: readonly (readonly PositionBlockRow[])[];
42
+ /** Shows Close on the trailing edge of the header. */
43
+ onClose?: () => void;
44
+ /** Shows Back on the leading edge of the header. */
45
+ onBack?: () => void;
46
+ /** A control on the trailing edge of the header in place of Close. */
47
+ headerAction?: React.ReactNode;
48
+ testID?: string;
49
+ }
50
+ /** The position being opened or edited as a screen: a summary of what it costs and where it ends, an optional paper trading switch, and its settings as grouped rows that open the host's own views. */
51
+ export declare function PositionBlock({ title, details, note, paperTrade, groups, onClose, onBack, headerAction, testID }: PositionBlockProps): React.JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { View } from 'react-native';
3
+ import { useColors, useFills, useHIG, useMessages } from './provider.js';
4
+ import { Text } from './surface.js';
5
+ import { IconButton } from './button.js';
6
+ import { ChevronIcon, CloseIcon } from './icons.js';
7
+ import { SwitchRow } from './switch-row.js';
8
+ import { ListGroup, ListRow } from './list-group.js';
9
+ import { AnimatedNumberReadout } from './animated-number.js';
10
+ import { formatNumberReadout } from './animated-number-model.js';
11
+ const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
12
+ /** The position being opened or edited as a screen: a summary of what it costs and where it ends, an optional paper trading switch, and its settings as grouped rows that open the host's own views. */
13
+ export function PositionBlock({ title, details, note, paperTrade, groups, onClose, onBack, headerAction, testID }) {
14
+ const colors = useColors(), fills = useFills(), t = useMessages(), { direction, locale } = useHIG();
15
+ const figure = { fontSize: 16, lineHeight: 24, fontWeight: '500' };
16
+ const shown = groups.filter(group => group.length > 0);
17
+ return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [_jsxs(View, { testID: 'position-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: 'position-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'position-title', accessibilityRole: 'header', numberOfLines: 1, style: { flex: 1, textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: colors.text }, children: title }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: headerAction ?? (onClose ? _jsx(IconButton, { intent: 'ghost', label: t.close, suppressFeedback: true, testID: 'position-close', onPress: onClose, children: _jsx(CloseIcon, { color: colors.text }) }) : null) })] }), details.length > 0 ? _jsx(View, { testID: 'position-details', style: { gap: 12, marginTop: 16, paddingHorizontal: 20 }, children: details.map((detail, index) => {
18
+ const live = typeof detail.value === 'string' ? null : detail.value, reading = live ? formatNumberReadout(live.value, locale, live.options, undefined, live.prefix, live.suffix).text : detail.value;
19
+ return _jsxs(View, { testID: `position-detail-${detail.id ?? index}`, accessible: true, accessibilityLabel: `${detail.label}, ${reading}`, style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12 }, children: [_jsx(Text, { ...hidden, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, color: colors.muted }, children: detail.label }), _jsx(View, { ...hidden, style: { flexShrink: 1 }, children: live ? _jsx(AnimatedNumberReadout, { ...live, tone: detail.tone ?? 'text', style: figure }) : _jsx(Text, { style: { ...figure, color: detail.tone ? colors[detail.tone] : colors.text, textAlign: 'right' }, children: reading }) })] }, detail.id ?? index);
20
+ }) }) : null, note ? _jsx(Text, { testID: 'position-note', style: { color: colors.muted, fontSize: 13, lineHeight: 20, marginTop: 8, paddingHorizontal: 20 }, children: note }) : null, paperTrade || shown.length > 0 ? _jsxs(View, { testID: 'position-groups', style: { gap: 24, marginTop: 16 }, children: [paperTrade ? _jsx(SwitchRow, { testID: 'position-paper-trade', label: paperTrade.label, checked: paperTrade.checked, disabled: paperTrade.disabled, onCheckedChange: paperTrade.onCheckedChange, style: { minHeight: 56, paddingVertical: 8, paddingHorizontal: 20, borderRadius: 20, backgroundColor: fills.well, opacity: paperTrade.disabled ? 0.5 : 1 }, children: _jsxs(View, { style: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [_jsx(Text, { style: { flex: 1, flexShrink: 1, minWidth: 0, fontSize: 16, lineHeight: 24, color: colors.text }, children: paperTrade.label }), _jsx(View, { testID: 'position-paper-trade-track', style: { width: 40, height: 24, borderRadius: 12, padding: 3, backgroundColor: paperTrade.checked ? colors.action : fills.raised, alignItems: paperTrade.checked ? 'flex-end' : 'flex-start' }, children: _jsx(View, { style: { width: 18, height: 18, borderRadius: 9, backgroundColor: paperTrade.checked ? colors.onAction : colors.text } }) })] }) }) : null, shown.map((group, index) => _jsx(ListGroup, { testID: `position-group-${index}`, children: group.map(row => _jsx(ListRow, { testID: `position-row-${row.id}`, label: row.label, value: row.value, onSelect: row.onSelect, disabled: row.disabled }, row.id)) }, index))] }) : null] });
21
+ }
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import type { AssetArtwork } from './asset-balance-row.js';
3
+ export type { AssetArtwork } from './asset-balance-row.js';
4
+ /** One row of a profile section. The host supplies every label and value. */
5
+ export interface ProfileRow {
6
+ id: string;
7
+ label: string;
8
+ leading?: React.ReactNode;
9
+ value?: React.ReactNode;
10
+ trailing?: React.ReactNode;
11
+ onSelect?: () => void;
12
+ disabled?: boolean;
13
+ /** With `onCheckedChange`, the row is a switch: the track trails and the label names it. */
14
+ checked?: boolean;
15
+ onCheckedChange?: (checked: boolean) => void;
16
+ }
17
+ export interface ProfileSection {
18
+ id: string;
19
+ /** Heading above the group, such as Rewards or Settings. */
20
+ title?: string;
21
+ rows: readonly ProfileRow[];
22
+ }
23
+ export interface ProfileStatus {
24
+ /** Read out for the dot, for example Demo. */
25
+ label: string;
26
+ tone?: 'positive' | 'warning' | 'negative' | 'info';
27
+ }
28
+ export interface ProfileBlockProps {
29
+ /** The name under the avatar: a display name or a shortened address. */
30
+ name: string;
31
+ /** Colours the avatar when there is no artwork. */
32
+ address?: string;
33
+ avatar?: AssetArtwork;
34
+ status?: ProfileStatus;
35
+ onEditName?: () => void;
36
+ onShowAddress?: () => void;
37
+ onClose?: () => void;
38
+ sections: readonly ProfileSection[];
39
+ testID?: string;
40
+ }
41
+ /** A person's profile as one screen: the address and close controls, the avatar with its status, the name, then the host's sections of rows. */
42
+ export declare function ProfileBlock({ name, address, avatar, status, onEditName, onShowAddress, onClose, sections, testID }: ProfileBlockProps): React.JSX.Element;
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Image, Pressable, View } from 'react-native';
3
+ import { useColors, useFills, useHIG, useMessages } from './provider.js';
4
+ import { Text } from './surface.js';
5
+ import { CloseIcon, EditIcon, QrIcon } from './icons.js';
6
+ import { ListGroup, ListRow } from './list-group.js';
7
+ import { SwitchRow } from './switch-row.js';
8
+ import { addressColor } from './swap-shared.js';
9
+ const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
10
+ /** A round 44 control with no fill of its own, like the other block headers; it takes the well fill while pressed. */
11
+ function RoundButton({ label, testID, onPress, children }) {
12
+ const fills = useFills();
13
+ return _jsx(Pressable, { testID: testID, accessibilityRole: 'button', accessibilityLabel: label, onPress: onPress, hitSlop: { top: 2, bottom: 2 }, style: ({ pressed }) => ({ width: 44, height: 44, borderRadius: 22, alignItems: 'center', justifyContent: 'center', backgroundColor: pressed ? fills.well : 'transparent' }), children: children });
14
+ }
15
+ /** A list row that is one switch: the same anatomy as ListRow, with the track on the trailing edge, level with the first line of the label. */
16
+ function ProfileSwitchRow({ row }) {
17
+ const colors = useColors(), fills = useFills();
18
+ const on = !!row.checked;
19
+ const first = { minHeight: 40, justifyContent: 'center' };
20
+ return _jsx(SwitchRow, { testID: `profile-row-${row.id}`, label: row.label, checked: on, disabled: row.disabled, onCheckedChange: row.onCheckedChange, style: { minHeight: 56, paddingVertical: 8, paddingHorizontal: 20, backgroundColor: fills.well, opacity: row.disabled ? 0.5 : 1 }, children: _jsxs(View, { style: { flex: 1, flexDirection: 'row', alignItems: 'flex-start', gap: 12 }, children: [row.leading == null ? null : _jsx(View, { style: first, children: row.leading }), _jsx(Text, { style: { flex: 1, flexShrink: 1, minWidth: 0, paddingVertical: 8, fontSize: 16, lineHeight: 24, color: colors.text }, children: row.label }), _jsx(View, { style: first, children: _jsx(View, { testID: `profile-row-${row.id}-track`, style: { width: 40, height: 24, borderRadius: 12, padding: 3, backgroundColor: on ? colors.action : fills.raised, alignItems: on ? 'flex-end' : 'flex-start' }, children: _jsx(View, { style: { width: 18, height: 18, borderRadius: 9, backgroundColor: on ? colors.onAction : colors.text } }) }) })] }) });
21
+ }
22
+ /** A person's profile as one screen: the address and close controls, the avatar with its status, the name, then the host's sections of rows. */
23
+ export function ProfileBlock({ name, address, avatar, status, onEditName, onShowAddress, onClose, sections, testID }) {
24
+ const colors = useColors(), fills = useFills(), t = useMessages(), { direction } = useHIG();
25
+ const art = typeof avatar === 'string' ? _jsx(Image, { source: { uri: avatar }, style: { width: 144, height: 144 } }) : avatar ?? (address ? null : _jsx(Text, { style: { fontSize: 40, lineHeight: 48, fontWeight: '600', color: colors.muted }, children: name.slice(0, 2) }));
26
+ const shown = sections.filter(section => section.rows.length > 0);
27
+ return _jsxs(View, { testID: testID, style: { direction, padding: 16 }, children: [_jsxs(View, { testID: 'profile-bar', style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', minHeight: 44 }, children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onShowAddress ? _jsx(RoundButton, { label: t.showAddress, testID: 'profile-address', onPress: onShowAddress, children: _jsx(QrIcon, { color: colors.text }) }) : null }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: onClose ? _jsx(RoundButton, { label: t.close, testID: 'profile-close', onPress: onClose, children: _jsx(CloseIcon, { color: colors.text }) }) : null })] }), _jsxs(View, { style: { alignSelf: 'center', width: 144, height: 144, marginTop: 8 }, children: [_jsx(View, { ...hidden, testID: 'profile-avatar', style: { width: 144, height: 144, borderRadius: 72, overflow: 'hidden', alignItems: 'center', justifyContent: 'center', backgroundColor: avatar == null && address ? addressColor(address) : fills.well }, children: art }), status ? _jsx(View, { testID: 'profile-status', accessible: true, accessibilityLabel: status.label, style: { position: 'absolute', top: 10, end: 10, width: 20, height: 20, borderRadius: 10, borderWidth: 3, borderColor: colors.background, backgroundColor: colors[status.tone ?? 'warning'] } }) : null] }), _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 4, marginTop: 16 }, children: [_jsx(Text, { testID: 'profile-name', accessibilityRole: 'header', numberOfLines: 1, style: { flexShrink: 1, fontSize: 28, lineHeight: 34, fontWeight: '700', color: colors.text }, children: name }), onEditName ? _jsx(Pressable, { testID: 'profile-edit', accessibilityRole: 'button', accessibilityLabel: t.editName, onPress: onEditName, style: ({ pressed }) => ({ width: 44, height: 44, alignItems: 'center', justifyContent: 'center', opacity: pressed ? 0.6 : 1 }), children: _jsx(EditIcon, { color: colors.muted }) }) : null] }), shown.length > 0 ? _jsx(View, { testID: 'profile-sections', style: { gap: 24, marginTop: 24 }, children: shown.map(section => _jsx(ListGroup, { testID: `profile-section-${section.id}`, title: section.title, children: section.rows.map(row => row.onCheckedChange ? _jsx(ProfileSwitchRow, { row: row }, row.id) : _jsx(ListRow, { testID: `profile-row-${row.id}`, label: row.label, leading: row.leading, value: row.value, trailing: row.trailing, onSelect: row.onSelect, disabled: row.disabled }, row.id)) }, section.id)) }) : null] });
28
+ }