@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.
- package/chart/README.md +1 -1
- package/contracts/README.md +1 -1
- package/contracts/dist/index.d.ts +16 -0
- package/contracts/dist/index.js +22 -0
- package/contracts/dist/messages.d.ts +6 -0
- package/contracts/dist/messages.js +3 -1
- package/feedback/README.md +1 -1
- package/native/README.md +1 -1
- package/native/dist/account-block.d.ts +53 -7
- package/native/dist/account-block.js +42 -9
- package/native/dist/animated-number-model.d.ts +7 -1
- package/native/dist/animated-number-model.js +50 -1
- package/native/dist/animated-number.d.ts +3 -1
- package/native/dist/animated-number.js +8 -5
- package/native/dist/asset-balance-row.d.ts +17 -1
- package/native/dist/asset-balance-row.js +13 -8
- package/native/dist/bar-mark.d.ts +14 -2
- package/native/dist/bar-mark.js +19 -5
- package/native/dist/bar-pnl.js +5 -4
- package/native/dist/blocks.d.ts +8 -14
- package/native/dist/blocks.js +5 -6
- package/native/dist/button.js +3 -1
- package/native/dist/data.d.ts +1 -1
- package/native/dist/data.js +6 -4
- package/native/dist/field.d.ts +14 -4
- package/native/dist/field.js +33 -7
- package/native/dist/figure.d.ts +23 -0
- package/native/dist/figure.js +10 -0
- package/native/dist/language-block.d.ts +5 -1
- package/native/dist/language-block.js +3 -3
- package/native/dist/list-group.d.ts +42 -8
- package/native/dist/list-group.js +71 -13
- package/native/dist/manage-position-block.d.ts +28 -2
- package/native/dist/manage-position-block.js +36 -11
- package/native/dist/market-row.d.ts +46 -0
- package/native/dist/market-row.js +30 -0
- package/native/dist/notifications-block.d.ts +30 -2
- package/native/dist/notifications-block.js +16 -8
- package/native/dist/pickers.d.ts +24 -2
- package/native/dist/pickers.js +16 -8
- package/native/dist/position-block.d.ts +66 -10
- package/native/dist/position-block.js +45 -11
- package/native/dist/profile-block.d.ts +29 -5
- package/native/dist/profile-block.js +25 -5
- package/native/dist/provider.d.ts +9 -3
- package/native/dist/provider.js +7 -3
- package/native/dist/radio-group.d.ts +9 -3
- package/native/dist/radio-group.js +4 -5
- package/native/dist/recipes.d.ts +6 -0
- package/native/dist/recipes.js +6 -0
- package/native/dist/reward-block.d.ts +45 -6
- package/native/dist/reward-block.js +30 -12
- package/native/dist/screen-header.d.ts +49 -0
- package/native/dist/screen-header.js +29 -0
- package/native/dist/selection.d.ts +2 -2
- package/native/dist/setting-header.d.ts +2 -8
- package/native/dist/setting-header.js +2 -11
- package/native/dist/setting-switch.d.ts +14 -1
- package/native/dist/setting-switch.js +5 -2
- package/native/dist/signals-block.d.ts +26 -2
- package/native/dist/signals-block.js +14 -4
- package/native/dist/sound-haptics-block.d.ts +29 -2
- package/native/dist/sound-haptics-block.js +18 -7
- package/native/dist/status.d.ts +6 -5
- package/native/dist/status.js +5 -5
- package/native/dist/sticky-header.d.ts +28 -0
- package/native/dist/sticky-header.js +21 -0
- package/native/dist/surface.d.ts +3 -1
- package/native/dist/surface.js +2 -1
- package/native/dist/swap-panel-block.d.ts +2 -1
- package/native/dist/swap-panel-block.js +9 -6
- package/native/dist/swap-parts.d.ts +5 -3
- package/native/dist/swap-parts.js +2 -2
- package/native/dist/swap-shared.d.ts +6 -0
- package/native/dist/swap-views.js +5 -3
- package/native/dist/switch-row.d.ts +3 -2
- package/native/dist/switch-row.js +5 -3
- package/native/dist/switch.d.ts +4 -2
- package/native/dist/switch.js +3 -3
- package/native/dist/target-block.d.ts +33 -6
- package/native/dist/target-block.js +19 -6
- package/native/dist/token-action-block.d.ts +17 -9
- package/native/dist/token-action-block.js +14 -6
- package/native/dist/trade-history-detail-block.d.ts +26 -1
- package/native/dist/trade-history-detail-block.js +17 -9
- package/native/dist/trade-history-list-block.d.ts +71 -5
- package/native/dist/trade-history-list-block.js +50 -15
- package/native/dist/wallet-address-core.d.ts +25 -0
- package/native/dist/wallet-address-core.js +31 -0
- package/native/dist/wallet-address.d.ts +6 -10
- package/native/dist/wallet-address.js +16 -20
- package/native-fonts/README.md +1 -1
- package/og-fonts/README.md +1 -1
- package/package.json +21 -1
- package/react/README.md +1 -1
- package/react/dist/animated-number-model.d.ts +6 -0
- package/react/dist/animated-number-model.js +33 -0
- package/react/dist/animated-number.d.ts +5 -1
- package/react/dist/animated-number.js +12 -8
- package/react/dist/asset-balance-row.d.ts +17 -1
- package/react/dist/asset-balance-row.js +11 -3
- package/react/dist/bar-mark.d.ts +5 -2
- package/react/dist/bar-mark.js +5 -3
- package/react/dist/blocks/account-block.d.ts +53 -7
- package/react/dist/blocks/account-block.js +45 -10
- package/react/dist/blocks/language-block.d.ts +5 -1
- package/react/dist/blocks/language-block.js +6 -5
- package/react/dist/blocks/manage-position-block.d.ts +28 -2
- package/react/dist/blocks/manage-position-block.js +23 -4
- package/react/dist/blocks/market-row.d.ts +20 -9
- package/react/dist/blocks/market-row.js +12 -4
- package/react/dist/blocks/notifications-block.d.ts +25 -2
- package/react/dist/blocks/notifications-block.js +11 -2
- package/react/dist/blocks/pickers.d.ts +21 -1
- package/react/dist/blocks/pickers.js +30 -10
- package/react/dist/blocks/position-block.d.ts +34 -11
- package/react/dist/blocks/position-block.js +16 -5
- package/react/dist/blocks/profile-block.d.ts +29 -6
- package/react/dist/blocks/profile-block.js +31 -5
- package/react/dist/blocks/reward-block.d.ts +53 -14
- package/react/dist/blocks/reward-block.js +20 -10
- package/react/dist/blocks/screen-header.d.ts +26 -2
- package/react/dist/blocks/screen-header.js +13 -5
- package/react/dist/blocks/setting-switch.d.ts +14 -1
- package/react/dist/blocks/setting-switch.js +8 -4
- package/react/dist/blocks/signals-block.d.ts +21 -2
- package/react/dist/blocks/signals-block.js +5 -5
- package/react/dist/blocks/sound-haptics-block.d.ts +25 -3
- package/react/dist/blocks/sound-haptics-block.js +11 -7
- package/react/dist/blocks/sticky-header.d.ts +9 -0
- package/react/dist/blocks/sticky-header.js +43 -0
- package/react/dist/blocks/swap/amount-card.js +2 -1
- package/react/dist/blocks/swap/settings.js +2 -2
- package/react/dist/blocks/swap/shared.d.ts +7 -1
- package/react/dist/blocks/swap/shared.js +6 -4
- package/react/dist/blocks/swap-panel-block.d.ts +2 -0
- package/react/dist/blocks/swap-panel-block.js +6 -6
- package/react/dist/blocks/target-block.d.ts +28 -6
- package/react/dist/blocks/target-block.js +17 -9
- package/react/dist/blocks/token-action-block.d.ts +17 -8
- package/react/dist/blocks/token-action-block.js +9 -6
- package/react/dist/blocks/trade-history-detail-block.d.ts +21 -1
- package/react/dist/blocks/trade-history-detail-block.js +5 -4
- package/react/dist/blocks/trade-history-list-block.d.ts +29 -5
- package/react/dist/blocks/trade-history-list-block.js +15 -8
- package/react/dist/blocks.d.ts +8 -8
- package/react/dist/blocks.js +2 -2
- package/react/dist/button.js +6 -4
- package/react/dist/data.js +3 -3
- package/react/dist/field.d.ts +14 -4
- package/react/dist/field.js +19 -6
- package/react/dist/figure.d.ts +23 -0
- package/react/dist/figure.js +12 -0
- package/react/dist/list-group.d.ts +41 -8
- package/react/dist/list-group.js +44 -12
- package/react/dist/provider.d.ts +40 -3
- package/react/dist/provider.js +63 -6
- package/react/dist/selection.d.ts +8 -2
- package/react/dist/selection.js +11 -6
- package/react/dist/styles.css +164 -9
- package/react/dist/surface.d.ts +5 -1
- package/react/dist/surface.js +1 -1
- package/react/dist/wallet-address-core.d.ts +23 -0
- package/react/dist/wallet-address-core.js +24 -0
- package/react/dist/wallet-address.d.ts +6 -12
- package/react/dist/wallet-address.js +5 -16
- package/tokens/README.md +1 -1
|
@@ -2,10 +2,11 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { Animated, BackHandler, Easing, Platform, Pressable, StyleSheet, View } from 'react-native';
|
|
4
4
|
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
5
|
-
import { Raised, useColors, useControllable, useHIG, useMessages } from './provider.js';
|
|
5
|
+
import { Raised, useColors, useControllable, useHIG, useMessages, useNumberLocale, usePresentNumber } from './provider.js';
|
|
6
6
|
import { Text } from './surface.js';
|
|
7
7
|
import { Button, IconButton } from './button.js';
|
|
8
8
|
import { AnimatedNumberReadout } from './animated-number.js';
|
|
9
|
+
import { figureProps } from './figure.js';
|
|
9
10
|
import { Toast, useTransientNotice } from './status.js';
|
|
10
11
|
import { VerticalAddress, addressKind } from './data.js';
|
|
11
12
|
import { withAlpha } from '@bloxwap/hig/tokens';
|
|
@@ -22,7 +23,9 @@ export { SwapHostContext } from './swap-parts.js';
|
|
|
22
23
|
*/
|
|
23
24
|
export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains, hotTokenIds, from: fromProp, to: toProp, defaultFrom = null, defaultTo = null, onFromChange, onToChange, amount, onAmountChange, received, fee, fees, quoteLoading, slippage = 0.005, onSlippageChange, denomination, onDenominationChange, wallet, onConnect, onDisconnect, recipient, onRecipientChange, onScanRecipient, receive, receiving, onReceivingChange, onSubmit, submitting = false, onReset, keypad = 'auto', destination, details, note, noteTone = 'muted', title, onBack, controls = true, actionIcon, lockFrom = false, lockTo = false, actionLabel, actionDisabled = false, actionStatus, actionIntent = 'primary', limitToBalance = false, banner, footer, oneWay: oneWayProp = false, denominationSwitch = true, settings, view: viewProp, onViewChange, style }) {
|
|
24
25
|
const env = useHIG();
|
|
25
|
-
const {
|
|
26
|
+
const { direction } = env;
|
|
27
|
+
const locale = useNumberLocale();
|
|
28
|
+
const present = usePresentNumber();
|
|
26
29
|
const colors = useColors();
|
|
27
30
|
const t = useMessages();
|
|
28
31
|
const [from, setFrom] = useControllable(fromProp, defaultFrom, onFromChange);
|
|
@@ -105,13 +108,13 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
|
|
|
105
108
|
return chains; const seen = new Map(); for (const token of tokens)
|
|
106
109
|
if (!seen.has(token.chainId))
|
|
107
110
|
seen.set(token.chainId, { chainId: token.chainId, name: token.chain, icon: typeof token.chainIcon === 'string' ? token.chainIcon : undefined }); return [...seen.values()]; }, [chains, tokens]);
|
|
108
|
-
const usdText = (value) => formatNumber(value, locale, { style: 'currency', currency: 'USD' });
|
|
111
|
+
const usdText = (value) => formatNumber(value, locale, present({ style: 'currency', currency: 'USD' }));
|
|
109
112
|
const fraction = entry.includes('.') ? Math.min(entry.length - entry.indexOf('.') - 1, fromMode === 'usd' ? 2 : 8) : 0;
|
|
110
113
|
const smallType = { fontSize: 14, lineHeight: 19 }, small = { ...smallType, color: colors.muted };
|
|
111
114
|
// Live numbers: the fee and slippage sentences keep their translated wording around a number that updates in place.
|
|
112
115
|
const usdOptions = { style: 'currency', currency: 'USD' }, feeKnown = !quoteLoading && fee != null, feeAmount = quoteLoading ? '…' : fee != null ? usdText(fee) : '—', slippageText = formatPercent(slippage);
|
|
113
116
|
// An account (a token with a `caption`) reads name over caption beside one disc, and offers Max only.
|
|
114
|
-
const account = (side, token, locked) => _jsxs(_Fragment, { children: [_jsxs(View, { pointerEvents: 'none', testID: `swap-account-${side}`, style: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [_jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: _jsx(TokenArt, { uri: token.icon, symbol: token.symbol, size: 40 }) }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 4 }, children: [_jsx(Text, { style: { fontWeight: '600', lineHeight: 21, flexShrink: 1 }, children: token.name }), locked ? null : _jsx(View, { testID: `swap-account-chevron-${side}`, children: _jsx(SmallChevron, { color: colors.muted }) })] }), typeof token.caption === 'object' ? _jsx(AnimatedNumberReadout, { testID: 'swap-caption', ...token.caption, tone: 'muted', style: smallType }) : _jsx(Text, { style: small, children: token.caption })] })] }), side === 'from' && (token.balance ?? 0) > 0 ? _jsx(SwapCapsule, { testID: 'swap-max', onPress: () => setEntry(unitsToEntry(token.balance ?? 0, fromMode, fromPrice)), children: _jsx(Text, { style: small, children: t.swapMax }) }) : null] });
|
|
117
|
+
const account = (side, token, locked) => _jsxs(_Fragment, { children: [_jsxs(View, { pointerEvents: 'none', testID: `swap-account-${side}`, style: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [_jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: _jsx(TokenArt, { uri: token.icon, symbol: token.symbol, size: 40 }) }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 4 }, children: [_jsx(Text, { style: { fontWeight: '600', lineHeight: 21, flexShrink: 1 }, children: token.name }), locked ? null : _jsx(View, { testID: `swap-account-chevron-${side}`, children: _jsx(SmallChevron, { color: colors.muted }) })] }), typeof token.caption === 'object' ? _jsx(AnimatedNumberReadout, { testID: 'swap-caption', ...figureProps(token.caption), tone: 'muted', style: smallType }) : _jsx(Text, { style: small, children: token.caption })] })] }), side === 'from' && (token.balance ?? 0) > 0 ? _jsx(SwapCapsule, { testID: 'swap-max', onPress: () => setEntry(unitsToEntry(token.balance ?? 0, fromMode, fromPrice)), children: _jsx(Text, { style: small, children: t.swapMax }) }) : null] });
|
|
115
118
|
const header = (side, token) => _jsxs(_Fragment, { children: [_jsxs(View, { pointerEvents: 'none', style: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'flex-start', gap: 12 }, children: [_jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', style: { alignItems: 'center' }, children: [wallet?.address ? _jsx(View, { style: { width: 28, height: 28, borderRadius: 14, backgroundColor: addressColor(wallet.address), borderWidth: 2, borderColor: colors.surface } }) : null, token.chainIcon ? _jsx(TokenArt, { uri: token.chainIcon, size: 28, ring: colors.surface }) : null, _jsx(TokenArt, { uri: token.icon, symbol: token.symbol, size: 28, ring: colors.surface })].filter(Boolean).map((layer, index) => _jsx(View, { style: { marginTop: index ? -14 : 0 }, children: layer }, index)) }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [wallet?.address ? _jsx(Text, { style: small, children: shortAddress(wallet.address) }) : null, _jsx(Text, { style: small, children: token.chain }), _jsx(Text, { style: { fontWeight: '600', lineHeight: 21 }, children: token.name })] })] }), side === 'from' ? ((token.balance ?? 0) > 0 ? _jsxs(View, { pointerEvents: 'box-none', style: { alignItems: 'flex-end', gap: 8, maxWidth: '60%' }, children: [_jsxs(View, { pointerEvents: 'box-none', style: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'flex-end', gap: 8 }, children: [_jsx(SwapCapsule, { testID: 'swap-test', onPress: () => setEntry(unitsToEntry(testAmount(token), fromMode, fromPrice)), children: _jsx(Text, { style: small, children: t.swapTest }) }), _jsx(SwapCapsule, { testID: 'swap-max', onPress: () => setEntry(unitsToEntry(token.balance ?? 0, fromMode, fromPrice)), children: _jsx(Text, { style: small, children: t.swapMax }) })] }), _jsx(View, { pointerEvents: 'none', children: _jsx(AnimatedNumberReadout, { testID: 'swap-balance', value: token.balance, options: { maximumFractionDigits: 6 }, suffix: ` ${token.symbol}`, tone: 'muted', style: smallType }) })] }) : null)
|
|
116
119
|
: _jsxs(View, { pointerEvents: 'box-none', style: { alignItems: 'flex-end', gap: 8, maxWidth: '60%' }, children: [_jsx(SwapCapsule, { testID: 'swap-slippage', label: t.swapSlippage(slippageText), onPress: () => show(onSlippageChange ? 'slippage' : 'settings'), children: _jsx(SwapNumberText, { template: t.swapSlippage, text: slippageText, value: slippage * 100, formattedValue: slippageText.slice(0, -1), suffix: '%' }) }), _jsx(View, { pointerEvents: 'none', children: _jsx(SwapNumberText, { testID: 'swap-fee', template: t.swapFee, text: feeAmount, value: feeKnown ? fee : null, options: usdOptions }) })] })] });
|
|
117
120
|
const receiveView = (view) => {
|
|
@@ -132,8 +135,8 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
|
|
|
132
135
|
if (!fixed)
|
|
133
136
|
return null;
|
|
134
137
|
const art = !destination ? null : destination.icon ? _jsx(TokenArt, { uri: destination.icon, size: 40 }) : destination.address ? _jsx(View, { style: { width: 40, height: 40, borderRadius: 20, backgroundColor: addressColor(destination.address) } }) : _jsx(View, { style: { width: 40, height: 40, borderRadius: 20, backgroundColor: colors.nested, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: destination.title.slice(0, 2) }) });
|
|
135
|
-
const row = destination ? _jsxs(View, { pointerEvents: 'none', style: { flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 84, padding: 16 }, children: [_jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: art }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { testID: 'swap-destination-title', style: { fontWeight: destination.pending ? '500' : '600', lineHeight: 21 }, children: destination.title }), destination.subtitle ? _jsx(Text, { style: small, children: destination.subtitle }) : null, destination.address ? _jsx(Text, { style: small, children: shortAddress(destination.address) }) : null] }), destination.detail || fee !== undefined || destination.onPress ? _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8, maxWidth: '60%' }, children: [_jsxs(View, { style: { alignItems: 'flex-end', gap: 8, flexShrink: 1 }, children: [typeof destination.detail === 'object' ? _jsx(AnimatedNumberReadout, { testID: 'swap-destination-detail', ...destination.detail, tone: 'muted', style: { ...smallType, textAlign: 'right' } }) : destination.detail ? _jsx(Text, { style: [small, { textAlign: 'right' }], children: destination.detail }) : null, fee !== undefined ? _jsx(SwapNumberText, { testID: 'swap-destination-fee', align: 'right', template: t.swapFee, text: feeAmount, value: feeKnown ? fee : null, options: usdOptions }) : null] }), destination.onPress ? _jsx(View, { testID: 'swap-destination-chevron', children: _jsx(SmallChevron, { color: colors.muted, trailing: true }) }) : null] }) : null] }) : null;
|
|
136
|
-
const rows = details && details.length > 0 ? _jsx(View, { testID: 'swap-details', style: { gap: 12, padding: 16, paddingTop: destination ? 0 : 16 }, children: details.map(detail => _jsxs(View, { style: { flexDirection: 'row', justifyContent: 'space-between', gap: 12 }, children: [_jsx(Text, { style: { color: colors.muted, lineHeight: 21 }, children: detail.label }), typeof detail.value === 'number' ? _jsx(AnimatedNumberReadout, { value: detail.value, options: detail.options, prefix: detail.prefix, suffix: detail.suffix, style: { lineHeight: 21, textAlign: 'right' } }) : _jsx(Text, { style: { lineHeight: 21, textAlign: 'right', flexShrink: 1 }, children: detail.value })] }, detail.label)) }) : null;
|
|
138
|
+
const row = destination ? _jsxs(View, { pointerEvents: 'none', style: { flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 84, padding: 16 }, children: [_jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: art }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { testID: 'swap-destination-title', style: { fontWeight: destination.pending ? '500' : '600', lineHeight: 21 }, children: destination.title }), destination.subtitle ? _jsx(Text, { style: small, children: destination.subtitle }) : null, destination.address ? _jsx(Text, { style: small, children: shortAddress(destination.address) }) : null] }), destination.detail || fee !== undefined || destination.onPress ? _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8, maxWidth: '60%' }, children: [_jsxs(View, { style: { alignItems: 'flex-end', gap: 8, flexShrink: 1 }, children: [typeof destination.detail === 'object' ? _jsx(AnimatedNumberReadout, { testID: 'swap-destination-detail', ...figureProps(destination.detail), tone: 'muted', style: { ...smallType, textAlign: 'right' } }) : destination.detail ? _jsx(Text, { style: [small, { textAlign: 'right' }], children: destination.detail }) : null, fee !== undefined ? _jsx(SwapNumberText, { testID: 'swap-destination-fee', align: 'right', template: t.swapFee, text: feeAmount, value: feeKnown ? fee : null, options: usdOptions }) : null] }), destination.onPress ? _jsx(View, { testID: 'swap-destination-chevron', children: _jsx(SmallChevron, { color: colors.muted, trailing: true }) }) : null] }) : null] }) : null;
|
|
139
|
+
const rows = details && details.length > 0 ? _jsx(View, { testID: 'swap-details', style: { gap: 12, padding: 16, paddingTop: destination ? 0 : 16 }, children: details.map(detail => _jsxs(View, { style: { flexDirection: 'row', justifyContent: 'space-between', gap: 12 }, children: [_jsx(Text, { style: { color: colors.muted, lineHeight: 21 }, 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, style: { lineHeight: 21, textAlign: 'right' } }) : _jsx(Text, { style: { lineHeight: 21, textAlign: 'right', flexShrink: 1 }, children: detail.value })] }, detail.label)) }) : null;
|
|
137
140
|
const shape = { backgroundColor: colors.surface, borderRadius: 24, overflow: 'hidden' };
|
|
138
141
|
// With a pressable destination the whole card is the button; the rows inside it are read as part of it.
|
|
139
142
|
return destination?.onPress ? _jsx(Pressable, { accessibilityRole: 'button', accessibilityLabel: destination.title, testID: 'swap-destination', onPress: destination.onPress, style: ({ pressed }) => [shape, { opacity: pressed ? 0.85 : 1 }], children: _jsxs(Raised, { children: [row, rows] }) }) : _jsx(View, { testID: 'swap-destination', style: shape, children: _jsxs(Raised, { children: [row, rows] }) });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type FlatListProps } from 'react-native';
|
|
2
|
+
import { View, type FlatListProps, type Insets } from 'react-native';
|
|
3
3
|
import type { SwapArtwork, SwapToken } from './swap-shared.js';
|
|
4
4
|
/** What a host surface supplies to the swap views: a sheet passes its backend's list so drags hand off to the sheet, and turns off the panel's own height animation. */
|
|
5
5
|
export declare const SwapHostContext: React.Context<{
|
|
@@ -56,11 +56,13 @@ export declare function TokenIcon({ token, size }: {
|
|
|
56
56
|
size?: number;
|
|
57
57
|
}): React.JSX.Element;
|
|
58
58
|
/** Small capsule action that sits on a card: Max, Test, the slippage setting and the denomination switch. 32dp tall with a 44dp target. */
|
|
59
|
-
export declare function SwapCapsule({ children, onPress, label, testID }: {
|
|
59
|
+
export declare function SwapCapsule({ children, onPress, label, testID, hitSlop, ref }: {
|
|
60
60
|
children: React.ReactNode;
|
|
61
61
|
onPress: () => void;
|
|
62
62
|
label?: string;
|
|
63
|
-
testID?: string;
|
|
63
|
+
testID?: string; /** Defaults to a 44dp target, as on the swap card. */
|
|
64
|
+
hitSlop?: Insets; /** Reaches the capsule, for example to move accessibility focus back to it. */
|
|
65
|
+
ref?: React.Ref<View>;
|
|
64
66
|
}): React.JSX.Element;
|
|
65
67
|
/** Numeric keypad: a 3 by 4 grid of 56dp keys. Emits `0`–`9`, `.` or `back`. */
|
|
66
68
|
export declare function SwapKeypad({ onKey, label, deleteLabel }: {
|
|
@@ -42,10 +42,10 @@ export function TokenArt({ uri, symbol, size, ring }) {
|
|
|
42
42
|
/** Token artwork with its chain badge. */
|
|
43
43
|
export function TokenIcon({ token, size = 44 }) { const colors = useColors(); return _jsxs(View, { ...hidden, style: { width: size, height: size }, children: [_jsx(TokenArt, { uri: token.icon, symbol: token.symbol, size: size }), token.chainIcon ? _jsx(View, { style: { position: 'absolute', end: 0, bottom: 0 }, children: _jsx(TokenArt, { uri: token.chainIcon, size: 18, ring: colors.overlay }) }) : null] }); }
|
|
44
44
|
/** Small capsule action that sits on a card: Max, Test, the slippage setting and the denomination switch. 32dp tall with a 44dp target. */
|
|
45
|
-
export function SwapCapsule({ children, onPress, label, testID }) {
|
|
45
|
+
export function SwapCapsule({ children, onPress, label, testID, hitSlop = { top: 6, bottom: 6 }, ref }) {
|
|
46
46
|
const fills = useFills();
|
|
47
47
|
const { direction } = useHIG();
|
|
48
|
-
return _jsx(Pressable, { accessibilityRole: 'button', accessibilityLabel: label, testID: testID, onPress: onPress, hitSlop:
|
|
48
|
+
return _jsx(Pressable, { ref: ref, accessibilityRole: 'button', accessibilityLabel: label, testID: testID, onPress: onPress, hitSlop: hitSlop, style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', gap: 6, minHeight: 32, paddingVertical: 4, paddingHorizontal: 12, borderRadius: 9999, backgroundColor: pressed ? fills.raised : fills.well }), children: children });
|
|
49
49
|
}
|
|
50
50
|
const keys = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '0', 'back'];
|
|
51
51
|
/** Numeric keypad: a 3 by 4 grid of 56dp keys. Emits `0`–`9`, `.` or `back`. */
|
|
@@ -6,6 +6,8 @@ export interface SwapFigure {
|
|
|
6
6
|
options?: Intl.NumberFormatOptions;
|
|
7
7
|
prefix?: string;
|
|
8
8
|
suffix?: string;
|
|
9
|
+
/** Host-formatted text for `value`, drawn and read in place of Intl's and still moving place by place. Never parsed back. */
|
|
10
|
+
formattedValue?: string;
|
|
9
11
|
}
|
|
10
12
|
export interface SwapToken {
|
|
11
13
|
/** Unique per asset and chain, for example `${chainId}-${address}`. */
|
|
@@ -28,6 +30,10 @@ export interface SwapToken {
|
|
|
28
30
|
caption?: string | SwapFigure;
|
|
29
31
|
/** Extra text matched by the picker search, such as the contract address. */
|
|
30
32
|
keywords?: string;
|
|
33
|
+
/** Picker rows: host text after the balance figure, such as ` HYPE`. */
|
|
34
|
+
unitsSuffix?: string;
|
|
35
|
+
/** Picker rows: the second line under the name in place of the chain, for a list that is not about chains. The search still matches the chain. */
|
|
36
|
+
detail?: string;
|
|
31
37
|
}
|
|
32
38
|
/** An image URL, or an element the host draws. */
|
|
33
39
|
export type SwapArtwork = string | React.ReactElement;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { Pressable, View } from 'react-native';
|
|
4
4
|
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
5
|
-
import { useColors, useFills, useHIG, useMessages } from './provider.js';
|
|
5
|
+
import { useColors, useFills, useHIG, useMessages, useNumberLocale, usePresentNumber } from './provider.js';
|
|
6
6
|
import { Text } from './surface.js';
|
|
7
7
|
import { Field, Input } from './field.js';
|
|
8
8
|
import { SegmentedControl } from './radio-group.js';
|
|
@@ -21,11 +21,13 @@ export function SwapPicker({ side, onBack, selected, onSelect, wallet, onConnect
|
|
|
21
21
|
}
|
|
22
22
|
/** The settings views. Slippage and the fee breakdown push from the settings list, and Back returns to it. */
|
|
23
23
|
export function SwapSettings({ view, onViewChange, onBack, denomination, onDenominationChange, slippage, onSlippageChange, fee, fees, quoteLoading, children }) {
|
|
24
|
-
const {
|
|
24
|
+
const { direction } = useHIG();
|
|
25
|
+
const locale = useNumberLocale();
|
|
25
26
|
const colors = useColors();
|
|
26
27
|
const fills = useFills();
|
|
27
28
|
const t = useMessages();
|
|
28
|
-
const
|
|
29
|
+
const present = usePresentNumber();
|
|
30
|
+
const usd = (value) => formatNumber(value, locale, present({ style: 'currency', currency: 'USD' }));
|
|
29
31
|
const [custom, setCustom] = useState(null);
|
|
30
32
|
const title = view === 'slippage' ? t.swapSlippageTitle : view === 'fees' ? t.swapFees : t.swapSettings;
|
|
31
33
|
const feeText = quoteLoading ? '…' : fee != null ? usd(fee) : '—';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type PressableProps } from 'react-native';
|
|
2
|
+
import { View, type PressableProps } from 'react-native';
|
|
3
3
|
import type { CheckedProps } from './selection-types.js';
|
|
4
4
|
/** One named switch around a host's noninteractive label, description and track. */
|
|
5
5
|
export interface SwitchRowProps extends CheckedProps, Omit<PressableProps, 'children' | 'onPress' | 'disabled' | 'role' | 'accessibilityRole' | 'accessibilityLabel' | 'accessibilityLabelledBy' | 'aria-label' | 'aria-labelledby' | 'aria-checked' | 'aria-disabled'> {
|
|
6
6
|
/** Custom anatomy is decorative. `label` names the switch and `accessibilityHint` describes it. */ children: React.ReactNode;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
/** The ref reaches the row's Pressable. */
|
|
9
|
+
export declare const SwitchRow: React.ForwardRefExoticComponent<SwitchRowProps & React.RefAttributes<React.ComponentRef<typeof View>>>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
2
3
|
import { Platform, Pressable, View } from 'react-native';
|
|
3
4
|
import { useControllable, useHIG } from './provider.js';
|
|
4
|
-
|
|
5
|
+
/** The ref reaches the row's Pressable. */
|
|
6
|
+
export const SwitchRow = /* @__PURE__ */ forwardRef(function SwitchRow({ label, checked, defaultChecked = false, disabled, onCheckedChange, children, style, accessibilityState, ...props }, ref) {
|
|
5
7
|
const env = useHIG(), [current, set] = useControllable(checked, defaultChecked, onCheckedChange);
|
|
6
8
|
const toggle = () => { if (!disabled)
|
|
7
9
|
set(!current); };
|
|
@@ -14,5 +16,5 @@ export function SwitchRow({ label, checked, defaultChecked = false, disabled, on
|
|
|
14
16
|
toggle();
|
|
15
17
|
}
|
|
16
18
|
} } : {};
|
|
17
|
-
return _jsx(Pressable, { ...props, ...webKeys, accessible: true, accessibilityRole: 'switch', accessibilityLabel: label, accessibilityState: { ...accessibilityState, checked: current, disabled: !!disabled }, "aria-checked": current, "aria-busy": accessibilityState?.busy, disabled: disabled, onPress: toggle, style: state => [{ direction: env.direction, minHeight: 48, flexDirection: 'row' }, typeof style === 'function' ? style(state) : style], children: _jsx(View, { pointerEvents: 'none', accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', "aria-hidden": true, style: { flex: 1 }, children: children }) });
|
|
18
|
-
}
|
|
19
|
+
return _jsx(Pressable, { ...props, ...webKeys, ref: ref, accessible: true, accessibilityRole: 'switch', accessibilityLabel: label, accessibilityState: { ...accessibilityState, checked: current, disabled: !!disabled }, "aria-checked": current, "aria-busy": accessibilityState?.busy, disabled: disabled, onPress: toggle, style: state => [{ direction: env.direction, minHeight: 48, flexDirection: 'row' }, typeof style === 'function' ? style(state) : style], children: _jsx(View, { pointerEvents: 'none', accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', "aria-hidden": true, style: { flex: 1 }, children: children }) });
|
|
20
|
+
});
|
package/native/dist/switch.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ import type { CheckedProps } from './selection-types.js';
|
|
|
3
3
|
import { type AccentRole } from './roles.js';
|
|
4
4
|
export type { AccentRole } from './roles.js';
|
|
5
5
|
export interface SwitchProps extends CheckedProps {
|
|
6
|
-
tone?: AccentRole;
|
|
6
|
+
tone?: AccentRole; /** Draws the track alone: `label` still names the switch but is not shown, for a switch whose row already shows its name (such as a ListRow `trailing` control). */
|
|
7
|
+
hideLabel?: boolean;
|
|
8
|
+
testID?: string;
|
|
7
9
|
}
|
|
8
10
|
/** The off track is the dark `border` grey, so it reads as off on the page and on a card. On iOS/Android the whole labeled row is one 48dp switch target; the platform track is a hidden visual indicator. */
|
|
9
|
-
export declare function Switch({ label, checked, defaultChecked, disabled, tone, onCheckedChange }: SwitchProps): React.JSX.Element;
|
|
11
|
+
export declare function Switch({ label, checked, defaultChecked, disabled, tone, hideLabel, testID, onCheckedChange }: SwitchProps): React.JSX.Element;
|
|
10
12
|
export { SwitchRow, type SwitchRowProps } from './switch-row.js';
|
package/native/dist/switch.js
CHANGED
|
@@ -7,7 +7,7 @@ import { roleColor } from './roles.js';
|
|
|
7
7
|
/** react-native-web passes CSS transitions through style. */
|
|
8
8
|
const webEase = { transitionProperty: 'transform, background-color', transitionDuration: '150ms' };
|
|
9
9
|
/** The off track is the dark `border` grey, so it reads as off on the page and on a card. On iOS/Android the whole labeled row is one 48dp switch target; the platform track is a hidden visual indicator. */
|
|
10
|
-
export function Switch({ label, checked, defaultChecked = false, disabled, tone, onCheckedChange }) {
|
|
10
|
+
export function Switch({ label, checked, defaultChecked = false, disabled, tone, hideLabel, testID, onCheckedChange }) {
|
|
11
11
|
const env = useHIG();
|
|
12
12
|
const colors = useColors();
|
|
13
13
|
const fills = useFills();
|
|
@@ -20,11 +20,11 @@ export function Switch({ label, checked, defaultChecked = false, disabled, tone,
|
|
|
20
20
|
// otherwise paints the thumb with the app theme accent, Material teal, so it takes `text`). react-native-web's own Switch draws a
|
|
21
21
|
// Material thumb wider than its track in that off-palette teal and would nest a second control, so web draws the 40×24 capsule of
|
|
22
22
|
// @bloxwap/hig/react: an 18dp thumb inset 3dp that slides and eases over 150ms. RN Web presses on Enter; Space is handled here.
|
|
23
|
-
return _jsxs(Pressable, { accessibilityRole: 'switch', accessibilityLabel: label, accessibilityState: { checked: current, disabled: !!disabled }, "aria-checked": current, "aria-disabled": !!disabled, disabled: disabled, onPress: toggle, ...(web ? { onKeyDown: (event) => { if (event.key === ' ') {
|
|
23
|
+
return _jsxs(Pressable, { testID: testID, accessibilityRole: 'switch', accessibilityLabel: label, accessibilityState: { checked: current, disabled: !!disabled }, "aria-checked": current, "aria-disabled": !!disabled, disabled: disabled, onPress: toggle, ...(web ? { onKeyDown: (event) => { if (event.key === ' ') {
|
|
24
24
|
event.preventDefault();
|
|
25
25
|
if (!event.repeat)
|
|
26
26
|
toggle();
|
|
27
|
-
} } } : null), style: { direction: env.direction, minHeight: 48, flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', gap: tokens.space.md, opacity: web && disabled ? 0.5 : 1 }, children: [_jsx(Text, { children: label }), _jsx(View, { pointerEvents: 'none', accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', "aria-hidden": web || undefined, style: web ? [{ width: 40, height: 24, borderRadius: 12, padding: 3, backgroundColor: track[current ? 'true' : 'false'] }, webEase] : undefined, children: web ? _jsx(View, { style: [{ width: 18, height: 18, borderRadius: 9, backgroundColor: current ? colors.onAction : colors.text, transform: [{ translateX: (current ? 16 : 0) * (env.direction === 'rtl' ? -1 : 1) }] }, webEase] }) : _jsx(RNSwitch, { value: current, disabled: disabled, onValueChange: next => { if (!disabled)
|
|
27
|
+
} } } : null), style: { direction: env.direction, minHeight: 48, flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', gap: tokens.space.md, opacity: web && disabled ? 0.5 : 1 }, children: [hideLabel ? null : _jsx(Text, { children: label }), _jsx(View, { pointerEvents: 'none', accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', "aria-hidden": web || undefined, style: web ? [{ width: 40, height: 24, borderRadius: 12, padding: 3, backgroundColor: track[current ? 'true' : 'false'] }, webEase] : undefined, children: web ? _jsx(View, { style: [{ width: 18, height: 18, borderRadius: 9, backgroundColor: current ? colors.onAction : colors.text, transform: [{ translateX: (current ? 16 : 0) * (env.direction === 'rtl' ? -1 : 1) }] }, webEase] }) : _jsx(RNSwitch, { value: current, disabled: disabled, onValueChange: next => { if (!disabled)
|
|
28
28
|
set(next); }, trackColor: track, thumbColor: Platform.OS === 'android' ? colors.text : undefined, ios_backgroundColor: fills.raised }) })] });
|
|
29
29
|
}
|
|
30
30
|
export { SwitchRow } from './switch-row.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type ScrollViewProps } from 'react-native';
|
|
2
3
|
/** What the target does: close in profit, or cap the loss. */
|
|
3
4
|
export type TargetKind = 'take-profit' | 'stop-loss';
|
|
4
5
|
/** How the target is expressed: profit or loss in dollars, a price, or a share of the position. */
|
|
@@ -37,16 +38,18 @@ export interface TargetBlockProps {
|
|
|
37
38
|
/** Price the order triggers at. Defaults to `value` when the unit is `price`; otherwise unknown until the host supplies it. */
|
|
38
39
|
trigger?: number | null;
|
|
39
40
|
unit: TargetUnit;
|
|
40
|
-
/** Units offered, in order. Defaults to all three; one unit hides the control. */
|
|
41
|
-
units?: readonly TargetUnit[];
|
|
41
|
+
/** Units offered, in order. Defaults to all three; one unit hides the control. `{unit, disabled}` shows a unit that cannot be chosen now, dimmed. */
|
|
42
|
+
units?: readonly (TargetUnit | TargetUnitOption)[];
|
|
42
43
|
onUnitChange?: (unit: TargetUnit) => void;
|
|
43
44
|
/** The target in the current unit: signed dollars (2, -0.5), a price, or a signed fraction (0.05 reads +5%). `null` reads as unknown and disables the confirming action. */
|
|
44
45
|
value: number | null;
|
|
45
46
|
onValueChange?: (value: number) => void;
|
|
46
|
-
/** Quick choices in the current unit. The one equal to `value` is shown selected. */
|
|
47
|
-
presets?: readonly number[];
|
|
47
|
+
/** Quick choices in the current unit. The one equal to `value` is shown selected. `{value, disabled}` shows a choice that cannot be taken now, dimmed. */
|
|
48
|
+
presets?: readonly (number | TargetPreset)[];
|
|
48
49
|
/** Shows the Custom row; the host opens its own entry. */
|
|
49
50
|
onCustom?: () => void;
|
|
51
|
+
/** The value the host's own entry set, in the current unit. The Custom row then shows it on its trailing edge and reads as selected, and no quick choice does. Has no effect without `onCustom`; null keeps the row a toggle that reads as not selected. */
|
|
52
|
+
customValue?: number | null;
|
|
50
53
|
/** Format of prices. Defaults to US dollars. */
|
|
51
54
|
priceOptions?: Intl.NumberFormatOptions;
|
|
52
55
|
/** Set true to draw the prices inside a card: a surface fill, padding and radius. By default the title row, bar and readouts sit directly on the screen. */
|
|
@@ -59,10 +62,34 @@ export interface TargetBlockProps {
|
|
|
59
62
|
onCancel?: () => void;
|
|
60
63
|
/** Shows Back on the leading edge of the header. */
|
|
61
64
|
onBack?: () => void;
|
|
62
|
-
/** A control on the trailing edge of the header, usually an IconButton. It takes the place of the info button, and the note is then always shown. */
|
|
65
|
+
/** A control on the trailing edge of the header, usually an IconButton. It takes the place of the info button, and the note is then always shown, unless `headerActionBesideInfo` is set. */
|
|
63
66
|
headerAction?: React.ReactNode;
|
|
67
|
+
/** Set true to keep the info button when `headerAction` is given: the info button comes first and `headerAction` sits on the trailing edge. */
|
|
68
|
+
headerActionBesideInfo?: boolean;
|
|
69
|
+
/** Sets `nativeID` on the title, so a sheet around the pane can name itself with `accessibilityLabelledBy` (Android). */
|
|
70
|
+
headingId?: string;
|
|
71
|
+
/** Keeps the header pinned while the rest scrolls: the block becomes its own scroll view with the header as its sticky first child, transparent at rest and filled once content scrolls under it. Place it in a bounded container. */
|
|
72
|
+
stickyHeader?: boolean;
|
|
73
|
+
/** Fill behind the pinned header once content scrolls under it. Defaults to the background role; in a sheet pass the sheet's fill. */
|
|
74
|
+
stickyHeaderBackground?: string;
|
|
75
|
+
/** The scroll view used with `stickyHeader`, such as a sheet library's own. */
|
|
76
|
+
scrollComponent?: React.ComponentType<ScrollViewProps>;
|
|
64
77
|
testID?: string;
|
|
65
78
|
}
|
|
79
|
+
/** A quick choice that can be shown dimmed. */
|
|
80
|
+
export interface TargetPreset {
|
|
81
|
+
value: number;
|
|
82
|
+
disabled?: boolean;
|
|
83
|
+
}
|
|
84
|
+
/** A unit that can be shown dimmed. */
|
|
85
|
+
export interface TargetUnitOption {
|
|
86
|
+
unit: TargetUnit;
|
|
87
|
+
disabled?: boolean;
|
|
88
|
+
}
|
|
89
|
+
/** The quick choices as `{value, disabled}`, whichever form the host gave. */
|
|
90
|
+
export declare function targetPresets(presets: readonly (number | TargetPreset)[]): TargetPreset[];
|
|
91
|
+
/** The units as `{unit, disabled}`, whichever form the host gave. */
|
|
92
|
+
export declare function targetUnits(units: readonly (TargetUnit | TargetUnitOption)[]): TargetUnitOption[];
|
|
66
93
|
/** Number format of a target in a unit. Dollars and percents carry their sign; `short` drops the cents of a whole dollar amount, for a preset. */
|
|
67
94
|
export declare function targetFormat(unit: TargetUnit, priceOptions?: Intl.NumberFormatOptions, short?: number): Intl.NumberFormatOptions;
|
|
68
95
|
/**
|
|
@@ -80,4 +107,4 @@ export declare function targetLayout({ entry, trigger }: {
|
|
|
80
107
|
to: number;
|
|
81
108
|
};
|
|
82
109
|
/** A take profit or a stop loss on one position as a screen: the target as the headline figure, a price card whose bar shows how far the price is from the trigger, the unit, the host's quick choices, and the confirming action. The bar is decorative; each price reads its label and value. */
|
|
83
|
-
export declare function TargetBlock({ kind, labels, position, orderType, note, entry, trigger, unit, units, onUnitChange, value, onValueChange, presets, onCustom, priceOptions, surface, onSubmit, submitDisabled, busy, onCancel, onBack, headerAction, testID }: TargetBlockProps): React.JSX.Element;
|
|
110
|
+
export declare function TargetBlock({ kind, labels, position, orderType, note, entry, trigger, unit, units, onUnitChange, value, onValueChange, presets, onCustom, customValue, priceOptions, surface, onSubmit, submitDisabled, busy, onCancel, onBack, headerAction, headerActionBesideInfo, headingId, stickyHeader, stickyHeaderBackground, scrollComponent, testID }: TargetBlockProps): React.JSX.Element;
|
|
@@ -1,14 +1,19 @@
|
|
|
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 { useState } from 'react';
|
|
3
3
|
import { Pressable, View } from 'react-native';
|
|
4
4
|
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
5
|
-
import { useColors, useFills, useHIG, useMessages } from './provider.js';
|
|
5
|
+
import { useColors, useFills, useHIG, useMessages, useNumberLocale, usePresentNumber } from './provider.js';
|
|
6
|
+
import { StickyHeaderLayout } from './sticky-header.js';
|
|
6
7
|
import { Surface, Text } from './surface.js';
|
|
7
8
|
import { Button, IconButton } from './button.js';
|
|
8
9
|
import { SegmentedControl } from './radio-group.js';
|
|
9
10
|
import { ChevronIcon, SeverityIcon } from './icons.js';
|
|
10
11
|
import { AnimatedNumberReadout } from './animated-number.js';
|
|
11
12
|
import { formatNumberReadout } from './animated-number-model.js';
|
|
13
|
+
/** The quick choices as `{value, disabled}`, whichever form the host gave. */
|
|
14
|
+
export function targetPresets(presets) { return presets.map(preset => typeof preset === 'number' ? { value: preset } : preset); }
|
|
15
|
+
/** The units as `{unit, disabled}`, whichever form the host gave. */
|
|
16
|
+
export function targetUnits(units) { return units.map(unit => typeof unit === 'string' ? { unit } : unit); }
|
|
12
17
|
const usd = { style: 'currency', currency: 'USD' };
|
|
13
18
|
const allUnits = ['dollar', 'price', 'percent'];
|
|
14
19
|
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
@@ -45,11 +50,14 @@ export function targetLayout({ entry, trigger }) {
|
|
|
45
50
|
return start === undefined || end === undefined ? { positions, order, from: 0.5, to: 0.5 } : { positions, order, from: Math.min(start, end), to: Math.max(start, end) };
|
|
46
51
|
}
|
|
47
52
|
/** A take profit or a stop loss on one position as a screen: the target as the headline figure, a price card whose bar shows how far the price is from the trigger, the unit, the host's quick choices, and the confirming action. The bar is decorative; each price reads its label and value. */
|
|
48
|
-
export function TargetBlock({ kind, labels, position, orderType, note, entry, trigger, unit, units = allUnits, onUnitChange, value, onValueChange, presets = [], onCustom, priceOptions = usd, surface = false, onSubmit, submitDisabled, busy, onCancel, onBack, headerAction, testID }) {
|
|
53
|
+
export function TargetBlock({ kind, labels, position, orderType, note, entry, trigger, unit, units = allUnits, onUnitChange, value, onValueChange, presets = [], onCustom, customValue, priceOptions = usd, surface = false, onSubmit, submitDisabled, busy, onCancel, onBack, headerAction, headerActionBesideInfo, headingId, stickyHeader, stickyHeaderBackground, scrollComponent, testID }) {
|
|
49
54
|
const PriceCard = surface ? Surface : View;
|
|
50
|
-
const colors = useColors(), fills = useFills(), t = useMessages(), { direction, locale
|
|
55
|
+
const colors = useColors(), fills = useFills(), t = useMessages(), { direction } = useHIG(), locale = useNumberLocale(), present = usePresentNumber();
|
|
51
56
|
const [open, setOpen] = useState(false);
|
|
52
|
-
const info = note && labels.info && !headerAction ? labels.info : undefined;
|
|
57
|
+
const info = note && labels.info && (!headerAction || headerActionBesideInfo) ? labels.info : undefined;
|
|
58
|
+
// With the info button beside a host control, both header sides widen together so the title stays centred.
|
|
59
|
+
const pair = !!info && headerAction != null, side = pair ? 92 : 44;
|
|
60
|
+
const custom = onCustom && known(customValue) ? customValue : null, customText = custom === null ? null : formatNumber(custom, locale, present(targetFormat(unit, priceOptions)));
|
|
53
61
|
const target = trigger !== undefined ? trigger : unit === 'price' ? value : null;
|
|
54
62
|
const { positions, order, from, to } = targetLayout({ entry, trigger: target });
|
|
55
63
|
const prices = { entry, trigger: target };
|
|
@@ -57,5 +65,10 @@ export function TargetBlock({ kind, labels, position, orderType, note, entry, tr
|
|
|
57
65
|
const triggerLeads = (positions.trigger ?? 0) < (positions.entry ?? 0);
|
|
58
66
|
const align = (index) => order.length > 1 && index === order.length - 1 ? 'flex-end' : order.length === 3 && index === 1 ? 'center' : 'flex-start';
|
|
59
67
|
const part = (grow) => ({ flexGrow: grow, flexShrink: 1, flexBasis: 0, backgroundColor: fills.raised });
|
|
60
|
-
|
|
68
|
+
const sticky = !!stickyHeader;
|
|
69
|
+
const header = _jsxs(View, { testID: 'target-header', style: { flexDirection: 'row', alignItems: 'center', minHeight: 44 }, children: [_jsx(View, { style: { minWidth: side, alignItems: 'flex-start' }, children: onBack ? _jsx(IconButton, { intent: 'ghost', label: t.back, suppressFeedback: true, testID: 'target-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'target-title', nativeID: headingId, 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: side, alignItems: 'flex-end' }, children: info ? (() => { const button = _jsx(IconButton, { intent: 'ghost', label: info, suppressFeedback: true, testID: 'target-info', accessibilityState: { expanded: open }, onPress: () => setOpen(!open), children: _jsx(SeverityIcon, { kind: 'info', color: colors.text }) }); return pair ? _jsxs(View, { testID: 'target-header-actions', style: { direction, flexDirection: 'row', alignItems: 'center', gap: 4 }, children: [button, headerAction] }) : button; })() : headerAction })] });
|
|
70
|
+
const body = _jsxs(_Fragment, { children: [_jsx(View, { style: { alignItems: 'center', marginTop: 16 }, children: _jsx(AnimatedNumberReadout, { testID: 'target-amount', value: value, options: targetFormat(unit, priceOptions), style: { fontSize: 44, lineHeight: 50, fontWeight: '700', letterSpacing: -0.9, textAlign: 'center' } }) }), note && !info ? _jsx(Text, { testID: 'target-note', style: { color: colors.muted, fontSize: 14, lineHeight: 21, textAlign: 'center', marginTop: 16 }, children: note }) : null, _jsxs(PriceCard, { testID: 'target-prices', style: { gap: 12, marginTop: 16, minWidth: 0 }, children: [position || orderType ? _jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', justifyContent: 'space-between', gap: 12 }, children: [position ? _jsx(Text, { testID: 'target-position', accessibilityRole: 'header', style: { fontSize: 16, lineHeight: 24, fontWeight: '600', flexShrink: 1 }, children: position }) : _jsx(View, {}), orderType ? _jsx(Text, { testID: 'target-order-type', style: { color: colors.muted, fontSize: 14, lineHeight: 21, flexShrink: 1 }, children: orderType }) : null] }) : null, _jsxs(View, { ...hidden, testID: 'target-bar', style: { flexDirection: 'row', height: 24, borderRadius: 8, overflow: 'hidden' }, children: [_jsx(View, { style: part(from) }), to > from ? _jsx(View, { testID: 'target-move', style: { flexGrow: to - from, flexShrink: 1, flexBasis: 0, minWidth: 6, backgroundColor: tone, borderStartWidth: 3, borderEndWidth: 3, borderStartColor: triggerLeads ? tone : colors.text, borderEndColor: triggerLeads ? colors.text : tone } }) : null, _jsx(View, { style: part(1 - to) })] }), _jsx(View, { style: { flexDirection: 'row', justifyContent: 'space-between', gap: 12 }, children: order.map((price, index) => _jsxs(View, { accessible: true, accessibilityLabel: `${labels[price]}, ${formatNumberReadout(prices[price], locale, present(priceOptions)).text}`, testID: `target-${price}`, style: { alignItems: align(index), flexShrink: 1, minWidth: 0 }, children: [_jsx(View, { ...hidden, children: _jsx(AnimatedNumberReadout, { value: prices[price], options: priceOptions, tone: price === 'trigger' ? (stop ? 'negative' : 'positive') : 'text', style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) }), _jsx(Text, { ...hidden, numberOfLines: 1, style: { color: colors.muted, fontSize: 12, lineHeight: 16 }, children: labels[price] })] }, price)) })] }), units.length > 1 ? _jsx(View, { testID: 'target-units', style: { marginTop: 16 }, children: _jsx(SegmentedControl, { label: labels.unit, options: targetUnits(units).map(option => ({ value: option.unit, label: labels.units[option.unit], disabled: option.disabled })), value: unit, onValueChange: next => onUnitChange?.(next) }) }) : null, onCustom && customText === null ? _jsxs(Pressable, { testID: 'target-custom', accessibilityRole: 'button', accessibilityState: customValue !== undefined ? { selected: false } : undefined, onPress: onCustom, style: ({ pressed }) => ({ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 48, paddingHorizontal: 16, borderRadius: 9999, backgroundColor: pressed ? fills.raised : fills.well, marginTop: 16 }), children: [_jsx(Text, { numberOfLines: 1, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.text }, children: labels.custom }), _jsx(View, { ...hidden, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] }) : null, onCustom && customText !== null ? _jsxs(Pressable, { testID: 'target-custom', accessibilityRole: 'button', accessibilityLabel: `${labels.custom}, ${customText}`, accessibilityState: { selected: true }, onPress: onCustom, style: ({ pressed }) => ({ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 48, paddingHorizontal: 14, borderRadius: 9999, borderWidth: 2, borderColor: tone, backgroundColor: pressed ? fills.raised : fills.well, marginTop: 16 }), children: [_jsx(Text, { ...hidden, numberOfLines: 1, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.text }, children: labels.custom }), _jsxs(View, { ...hidden, style: { direction, flexDirection: 'row', alignItems: 'center', gap: 6, flexShrink: 1 }, children: [_jsx(Text, { testID: 'target-custom-value', numberOfLines: 1, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '500', color: tone }, children: customText }), _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] })] }) : null, presets.length > 0 ? _jsx(View, { testID: 'target-presets', style: { direction, flexDirection: 'row', gap: 8, marginTop: 16 }, children: targetPresets(presets).map(({ value: preset, disabled }) => { const selected = custom === null && preset === value; return _jsx(Button, { testID: `target-preset-${preset}`, intent: selected ? intent : 'secondary', disabled: disabled, accessibilityState: { selected }, onPress: () => onValueChange?.(preset), style: { flex: 1, alignSelf: 'auto', paddingHorizontal: 8 }, children: formatNumber(preset, locale, present(targetFormat(unit, priceOptions, preset))) }, preset); }) }) : null, info && open ? _jsx(Pressable, { testID: 'target-popover-dismiss', ...hidden, onPress: () => setOpen(false), style: { position: 'absolute', top: 0, bottom: 0, left: 0, right: 0, zIndex: 1 } }) : null, info && open ? _jsx(View, { testID: 'target-popover', accessibilityLiveRegion: 'polite', style: { position: 'absolute', top: sticky ? 4 : 64, ...(direction === 'rtl' ? { left: 16 } : { right: 16 }), maxWidth: 280, zIndex: 2, padding: 12, borderRadius: 14, backgroundColor: colors.nested }, children: _jsx(Text, { testID: 'target-note', style: { color: colors.text, fontSize: 14, lineHeight: 21 }, children: note }) }) : null, _jsxs(View, { testID: 'target-actions', style: { direction, flexDirection: 'row', gap: 8, marginTop: 16 }, children: [onCancel ? _jsx(Button, { testID: 'target-cancel', intent: 'secondary', onPress: onCancel, style: { flex: 1, alignSelf: 'auto' }, children: labels.cancel ?? t.cancel }) : null, _jsx(Button, { testID: 'target-submit', intent: intent, disabled: submitDisabled ?? value === null, busy: busy, onPress: onSubmit, style: { flex: 1, alignSelf: 'auto' }, children: labels.submit })] })] });
|
|
71
|
+
if (sticky)
|
|
72
|
+
return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: 'target-sticky-header', header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: body });
|
|
73
|
+
return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [header, body] });
|
|
61
74
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { HIGMessages } from '@bloxwap/hig/contracts/messages';
|
|
3
3
|
import { type BarMarkElement } from './bar-mark.js';
|
|
4
|
-
export type { BarMarkElement } from './bar-mark.js';
|
|
4
|
+
export type { BarMarkElement, BarMarkFigure } from './bar-mark.js';
|
|
5
5
|
/** The actions HIG names itself. */
|
|
6
6
|
export type TokenActionId = 'send' | 'receive' | 'stake' | 'unstake';
|
|
7
7
|
export interface TokenAction {
|
|
@@ -16,14 +16,20 @@ export interface TokenAction {
|
|
|
16
16
|
export interface TokenActionBlockProps {
|
|
17
17
|
/** Heading, usually the ticker: HYPE. */
|
|
18
18
|
symbol: string;
|
|
19
|
-
/** Title of the assets bar: Hyperliquid. */
|
|
20
|
-
name
|
|
19
|
+
/** Title of the assets bar: Hyperliquid. Needed only with `assets`; the symbol stands in without it. */
|
|
20
|
+
name?: string;
|
|
21
21
|
/** Total holding in dollars, on the trailing edge of the assets bar. Defaults to the sum of the asset values; null reads as unknown. */
|
|
22
22
|
value?: number | null;
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
|
|
23
|
+
/** The holding in token units, for a token with no dollar value: with `value` left out or null it is drawn in place of the dollar total. */
|
|
24
|
+
units?: number | null;
|
|
25
|
+
/** Host text after the units, such as ` BLOX`. */
|
|
26
|
+
unitsSuffix?: string;
|
|
27
|
+
/** Format of the units; default `{maximumFractionDigits:6}`. */
|
|
28
|
+
unitsOptions?: Intl.NumberFormatOptions;
|
|
29
|
+
/** Where the token is held: Staked, Core, Paper. Leave it out to draw no assets bar. */
|
|
30
|
+
assets?: readonly BarMarkElement[];
|
|
31
|
+
/** The chains the token sits on. Leave it out to draw no chains bar. */
|
|
32
|
+
chains?: readonly BarMarkElement[];
|
|
27
33
|
/** Title of the chains bar. Defaults to the built-in "Chains". */
|
|
28
34
|
chainsTitle?: string;
|
|
29
35
|
actions: readonly TokenAction[];
|
|
@@ -31,9 +37,11 @@ export interface TokenActionBlockProps {
|
|
|
31
37
|
onBack?: () => void;
|
|
32
38
|
/** A control on the trailing edge of the header, usually an IconButton. */
|
|
33
39
|
headerAction?: React.ReactNode;
|
|
40
|
+
/** A line under the actions, for example why some are missing. `noteTone` tints it as in SwapPanelBlock. */
|
|
41
|
+
note?: React.ReactNode;
|
|
42
|
+
noteTone?: 'muted' | 'warning' | 'negative';
|
|
34
43
|
testID?: string;
|
|
35
44
|
}
|
|
36
45
|
/** An action's text: its own `label`, else the built-in name of its id, else the id. */
|
|
37
46
|
export declare const tokenActionLabel: (action: TokenAction, messages: Partial<HIGMessages>) => string;
|
|
38
|
-
|
|
39
|
-
export declare function TokenActionBlock({ symbol, name, value, assets, chains, chainsTitle, actions, onBack, headerAction, testID }: TokenActionBlockProps): React.JSX.Element;
|
|
47
|
+
export declare function TokenActionBlock({ symbol, name, value, units, unitsSuffix, unitsOptions, assets, chains, chainsTitle, actions, onBack, headerAction, note, noteTone, testID }: TokenActionBlockProps): React.JSX.Element;
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
4
|
+
import { withAlpha } from '@bloxwap/hig/tokens';
|
|
4
5
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
|
-
import { useColors, useHIG, useMessages } from './provider.js';
|
|
6
|
+
import { useColors, useHIG, useMessages, useNumberLocale } from './provider.js';
|
|
6
7
|
import { Text } from './surface.js';
|
|
7
8
|
import { Button, IconButton } from './button.js';
|
|
8
9
|
import { ChevronIcon } from './icons.js';
|
|
9
10
|
import { AnimatedNumberReadout } from './animated-number.js';
|
|
10
|
-
import {
|
|
11
|
+
import { figureProps } from './figure.js';
|
|
12
|
+
import { BarMark, BarMarkFigureContext } from './bar-mark.js';
|
|
11
13
|
const usd = { style: 'currency', currency: 'USD' };
|
|
14
|
+
const unitsFormat = { maximumFractionDigits: 6 };
|
|
12
15
|
const held = (value) => Number.isFinite(value) && value > 0;
|
|
13
16
|
/** An action's text: its own `label`, else the built-in name of its id, else the id. */
|
|
14
17
|
export const tokenActionLabel = (action, messages) => action.label ?? (action.id === 'send' ? messages.swapActionSend ?? en.swapActionSend : action.id === 'receive' ? messages.receive ?? en.receive : action.id === 'stake' ? messages.stake ?? en.stake : action.id === 'unstake' ? messages.unstake ?? en.unstake : action.id);
|
|
15
18
|
/** One token as a screen: a header, where it is held, which chains it sits on, then what the user can do with it. */
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
/** Legend figures inside the block move place by place, like its total. */
|
|
20
|
+
const animatedFigure = (figure, { testID }) => _jsx(AnimatedNumberReadout, { ...figureProps(figure), tone: 'faint', testID: testID, style: { fontSize: 14, lineHeight: 21 } });
|
|
21
|
+
export function TokenActionBlock({ symbol, name, value, units, unitsSuffix, unitsOptions = unitsFormat, assets, chains, chainsTitle, actions, onBack, headerAction, note, noteTone = 'muted', testID }) {
|
|
22
|
+
const colors = useColors(), t = useMessages(), { direction } = useHIG(), locale = useNumberLocale();
|
|
23
|
+
const total = value !== undefined ? value : (assets ?? []).reduce((sum, asset) => sum + (held(asset.value) ? asset.value : 0), 0);
|
|
24
|
+
// With no dollar value the units are the headline, as an AccountBlock row headlines them.
|
|
25
|
+
const headline = units !== undefined && value == null ? _jsx(AnimatedNumberReadout, { value: units, options: unitsOptions, suffix: unitsSuffix, tone: 'muted', testID: 'token-units', style: { fontSize: 14, lineHeight: 21 } }, 'units') : _jsx(AnimatedNumberReadout, { value: total, options: usd, tone: 'muted', testID: 'token-value', style: { fontSize: 14, lineHeight: 21 } }, 'value');
|
|
26
|
+
const tone = noteTone === 'warning' ? colors.warning : noteTone === 'negative' ? colors.negative : null;
|
|
27
|
+
return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [_jsxs(View, { testID: 'token-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: 'token-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'token-title', accessibilityRole: 'header', numberOfLines: 1, style: { flex: 1, textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: colors.text }, children: symbol }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: headerAction })] }), assets || chains ? _jsx(BarMarkFigureContext.Provider, { value: animatedFigure, children: _jsxs(View, { testID: 'token-bars', style: { gap: 20, marginTop: 16, paddingHorizontal: 4 }, children: [assets ? _jsx(BarMark, { testID: 'token-assets', surface: false, title: name ?? symbol, elements: assets, description: headline }) : null, chains ? _jsx(BarMark, { testID: 'token-chains', surface: false, title: chainsTitle ?? t.swapChains, elements: chains, description: formatNumber(chains.filter(chain => held(chain.value)).length, locale) }) : null] }) }) : null, actions.length > 0 ? _jsx(View, { testID: 'token-actions', style: { gap: 8, marginTop: 16 }, children: actions.map(action => _jsx(Button, { testID: `token-action-${action.id}`, fullWidth: true, intent: action.intent ?? 'secondary', disabled: action.disabled, onPress: action.onSelect, children: tokenActionLabel(action, t) }, action.id)) }) : null, note != null && note !== false ? _jsx(View, { testID: 'token-note', style: [{ marginTop: actions.length > 0 ? 8 : 16 }, tone ? { paddingVertical: 12, paddingHorizontal: 16, borderRadius: 16, backgroundColor: withAlpha(tone, 0.1) } : { paddingHorizontal: 4 }], children: _jsx(Text, { style: { fontSize: 14, lineHeight: 21, color: tone ?? colors.muted }, children: note }) }) : null] });
|
|
20
28
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { View, type ScrollViewProps } from 'react-native';
|
|
2
3
|
import type { AssetArtwork } from './asset-balance-row.js';
|
|
3
4
|
export type { AssetArtwork } from './asset-balance-row.js';
|
|
4
5
|
/** The trading words of the block. HIG's built-in strings hold no trading terms, so the host supplies them, translated. */
|
|
@@ -21,6 +22,8 @@ export interface TradeHistoryDetail {
|
|
|
21
22
|
options?: Intl.NumberFormatOptions;
|
|
22
23
|
prefix?: string;
|
|
23
24
|
suffix?: string;
|
|
25
|
+
/** With a number `value`: host-formatted text drawn and read in place of Intl's, still moving place by place. */
|
|
26
|
+
formattedValue?: string;
|
|
24
27
|
}
|
|
25
28
|
export interface TradeHistoryAction {
|
|
26
29
|
id: string;
|
|
@@ -35,13 +38,27 @@ export interface TradeHistoryDetailBlockProps {
|
|
|
35
38
|
/** Asset name: Amazon. */
|
|
36
39
|
name: string;
|
|
37
40
|
icon?: AssetArtwork;
|
|
41
|
+
/** Short ticker for the fallback disc when there is no `icon`: BTC. Without it the disc shows the first letters of the name. */
|
|
42
|
+
symbol?: string;
|
|
38
43
|
side: 'long' | 'short';
|
|
39
44
|
/** 20 reads `20×`. */
|
|
40
45
|
leverage?: number;
|
|
46
|
+
/** A short muted qualifier after the leverage, read with it: current. */
|
|
47
|
+
leverageNote?: string;
|
|
41
48
|
/** Net profit and loss in dollars. `null` reads as unknown. */
|
|
42
49
|
pnl: number | null;
|
|
50
|
+
/** Format of the headline result. Defaults to signed US dollars with up to four decimals. The provider's `numberFormat` is merged under it. */
|
|
51
|
+
pnlOptions?: Intl.NumberFormatOptions;
|
|
43
52
|
/** Return on margin as a fraction: 0.0284 reads +2.84%. */
|
|
44
53
|
pnlPercent?: number | null;
|
|
54
|
+
/** Format of the return on margin. Defaults to a signed percent with two decimals. */
|
|
55
|
+
percentOptions?: Intl.NumberFormatOptions;
|
|
56
|
+
/** One muted sentence under the details, such as that part of the record is missing. */
|
|
57
|
+
note?: string;
|
|
58
|
+
/** Short host text in a badge beside the title: Demo. */
|
|
59
|
+
badge?: string;
|
|
60
|
+
/** Ref to a View around the summary (the asset line, the headline figure and the return), for a host that captures it as an image. Without it the summary has no wrapper. */
|
|
61
|
+
summaryRef?: React.Ref<View>;
|
|
45
62
|
/** Entry and exit prices. With both, one bar runs from entry to exit in the result colour, with the two prices under it, in place of two rows. */
|
|
46
63
|
entry?: number;
|
|
47
64
|
exit?: number;
|
|
@@ -53,7 +70,15 @@ export interface TradeHistoryDetailBlockProps {
|
|
|
53
70
|
onBack?: () => void;
|
|
54
71
|
/** A control on the trailing edge of the header, usually an IconButton. */
|
|
55
72
|
headerAction?: React.ReactNode;
|
|
73
|
+
/** Fills the View drawn with `summaryRef`, so an image captured from it is not transparent: `true` for the background role, or a colour such as the sheet's `useColors().overlay`. */
|
|
74
|
+
summaryBackground?: boolean | string;
|
|
75
|
+
/** Keeps the header pinned while the rest scrolls: the block becomes its own scroll view with the header as its sticky first child, transparent at rest and filled once content scrolls under it. Place it in a bounded container. */
|
|
76
|
+
stickyHeader?: boolean;
|
|
77
|
+
/** Fill behind the pinned header once content scrolls under it. Defaults to the background role; in a sheet pass the sheet's fill. */
|
|
78
|
+
stickyHeaderBackground?: string;
|
|
79
|
+
/** The scroll view used with `stickyHeader`, such as a sheet library's own. */
|
|
80
|
+
scrollComponent?: React.ComponentType<ScrollViewProps>;
|
|
56
81
|
testID?: string;
|
|
57
82
|
}
|
|
58
83
|
/** 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. */
|
|
59
|
-
export declare function TradeHistoryDetailBlock({ labels, name, icon, side, leverage, pnl, pnlPercent, entry, exit, priceOptions, details, actions, onBack, headerAction, testID }: TradeHistoryDetailBlockProps): React.JSX.Element;
|
|
84
|
+
export declare function TradeHistoryDetailBlock({ labels, name, icon, symbol, side, leverage, leverageNote, pnl, pnlOptions, pnlPercent, percentOptions, entry, exit, priceOptions, details, note, badge, summaryRef, summaryBackground, actions, onBack, headerAction, stickyHeader, stickyHeaderBackground, scrollComponent, testID }: TradeHistoryDetailBlockProps): React.JSX.Element;
|