@bloxwap/hig 0.5.2 → 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.
- package/README.md +1 -1
- package/chart/README.md +1 -1
- package/contracts/README.md +1 -1
- package/contracts/dist/messages.d.ts +31 -4
- package/contracts/dist/messages.js +11 -2
- package/feedback/README.md +1 -1
- package/native/README.md +1 -1
- package/native/dist/account-block.d.ts +46 -0
- package/native/dist/account-block.js +28 -0
- package/native/dist/asset-balance-row.d.ts +20 -0
- package/native/dist/asset-balance-row.js +21 -0
- package/native/dist/bar-mark.d.ts +45 -0
- package/native/dist/bar-mark.js +34 -0
- package/native/dist/bar-pnl.d.ts +50 -0
- package/native/dist/bar-pnl.js +59 -0
- package/native/dist/blocks.d.ts +44 -0
- package/native/dist/{recipes.js → blocks.js} +19 -9
- package/native/dist/field.d.ts +0 -1
- package/native/dist/field.js +0 -1
- package/native/dist/icons.d.ts +8 -0
- package/native/dist/icons.js +4 -0
- package/native/dist/language-block.d.ts +31 -0
- package/native/dist/language-block.js +30 -0
- package/native/dist/list-group.d.ts +26 -0
- package/native/dist/list-group.js +27 -0
- package/native/dist/manage-position-block.d.ts +69 -0
- package/native/dist/manage-position-block.js +57 -0
- package/native/dist/notifications-block.d.ts +25 -0
- package/native/dist/notifications-block.js +14 -0
- package/native/dist/pickers.d.ts +12 -4
- package/native/dist/pickers.js +6 -2
- package/native/dist/position-block.d.ts +51 -0
- package/native/dist/position-block.js +21 -0
- package/native/dist/profile-block.d.ts +42 -0
- package/native/dist/profile-block.js +28 -0
- package/native/dist/reward-block.d.ts +83 -0
- package/native/dist/reward-block.js +35 -0
- package/native/dist/setting-header.d.ts +8 -0
- package/native/dist/setting-header.js +11 -0
- package/native/dist/setting-switch.d.ts +18 -0
- package/native/dist/setting-switch.js +17 -0
- package/native/dist/signals-block.d.ts +37 -0
- package/native/dist/signals-block.js +16 -0
- package/native/dist/sound-haptics-block.d.ts +39 -0
- package/native/dist/sound-haptics-block.js +21 -0
- package/native/dist/{swap-panel.d.ts → swap-panel-block.d.ts} +6 -2
- package/native/dist/{swap-panel.js → swap-panel-block.js} +4 -2
- package/native/dist/swap-sheet.d.ts +4 -4
- package/native/dist/swap-sheet.js +4 -4
- package/native/dist/swap-views.d.ts +1 -1
- package/native/dist/swap-views.js +4 -4
- package/native/dist/target-block.d.ts +83 -0
- package/native/dist/target-block.js +61 -0
- package/native/dist/token-action-block.d.ts +39 -0
- package/native/dist/token-action-block.js +20 -0
- package/native/dist/trade-history-detail-block.d.ts +59 -0
- package/native/dist/trade-history-detail-block.js +38 -0
- package/native/dist/trade-history-list-block.d.ts +44 -0
- package/native/dist/trade-history-list-block.js +29 -0
- package/native-fonts/README.md +1 -1
- package/og-fonts/README.md +1 -1
- package/package.json +246 -41
- package/react/README.md +1 -1
- package/react/dist/asset-balance-row.d.ts +19 -0
- package/react/dist/asset-balance-row.js +10 -0
- package/react/dist/bar-mark.d.ts +35 -0
- package/react/dist/bar-mark.js +21 -0
- package/react/dist/bar-pnl.d.ts +49 -0
- package/react/dist/bar-pnl.js +45 -0
- package/react/dist/blocks/account-block.d.ts +46 -0
- package/react/dist/blocks/account-block.js +27 -0
- package/react/dist/blocks/language-block.d.ts +32 -0
- package/react/dist/blocks/language-block.js +51 -0
- package/react/dist/blocks/manage-position-block.d.ts +67 -0
- package/react/dist/blocks/manage-position-block.js +28 -0
- package/react/dist/blocks/notifications-block.d.ts +23 -0
- package/react/dist/blocks/notifications-block.js +8 -0
- package/react/dist/{recipes → blocks}/pickers.d.ts +12 -4
- package/react/dist/{recipes → blocks}/pickers.js +6 -2
- package/react/dist/blocks/position-block.d.ts +49 -0
- package/react/dist/blocks/position-block.js +14 -0
- package/react/dist/blocks/profile-block.d.ts +48 -0
- package/react/dist/blocks/profile-block.js +15 -0
- package/react/dist/blocks/reward-block.d.ts +81 -0
- package/react/dist/blocks/reward-block.js +24 -0
- package/react/dist/blocks/screen-header.d.ts +9 -0
- package/react/dist/blocks/screen-header.js +12 -0
- package/react/dist/blocks/setting-switch.d.ts +10 -0
- package/react/dist/blocks/setting-switch.js +8 -0
- package/react/dist/blocks/signals-block.d.ts +35 -0
- package/react/dist/blocks/signals-block.js +15 -0
- package/react/dist/blocks/sound-haptics-block.d.ts +37 -0
- package/react/dist/blocks/sound-haptics-block.js +18 -0
- package/react/dist/{recipes → blocks}/swap/picker.d.ts +1 -1
- package/react/dist/{recipes → blocks}/swap/picker.js +4 -4
- package/react/dist/{recipes → blocks}/swap/shared.d.ts +1 -0
- package/react/dist/{recipes → blocks}/swap/shared.js +1 -0
- package/react/dist/{recipes/swap-panel.d.ts → blocks/swap-panel-block.d.ts} +6 -2
- package/react/dist/{recipes/swap-panel.js → blocks/swap-panel-block.js} +3 -1
- package/react/dist/{recipes → blocks}/swap-sheet.d.ts +4 -4
- package/react/dist/{recipes → blocks}/swap-sheet.js +4 -4
- package/react/dist/blocks/target-block.d.ts +81 -0
- package/react/dist/blocks/target-block.js +65 -0
- package/react/dist/blocks/token-action-block.d.ts +37 -0
- package/react/dist/blocks/token-action-block.js +18 -0
- package/react/dist/{recipes → blocks}/trade-entry.js +2 -2
- package/react/dist/blocks/trade-history-detail-block.d.ts +58 -0
- package/react/dist/blocks/trade-history-detail-block.js +16 -0
- package/react/dist/blocks/trade-history-list-block.d.ts +43 -0
- package/react/dist/blocks/trade-history-list-block.js +21 -0
- package/react/dist/blocks.d.ts +20 -0
- package/react/dist/blocks.js +21 -0
- package/react/dist/field.d.ts +0 -2
- package/react/dist/field.js +0 -2
- package/react/dist/list-group.d.ts +26 -0
- package/react/dist/list-group.js +20 -0
- package/react/dist/styles.css +270 -5
- package/tokens/README.md +1 -1
- package/native/dist/recipes.d.ts +0 -46
- package/react/dist/recipes/activity-list.d.ts +0 -8
- package/react/dist/recipes/activity-list.js +0 -6
- package/react/dist/recipes/balance-card.d.ts +0 -6
- package/react/dist/recipes/balance-card.js +0 -5
- package/react/dist/recipes/code-window.d.ts +0 -4
- package/react/dist/recipes/code-window.js +0 -4
- package/react/dist/recipes.d.ts +0 -10
- package/react/dist/recipes.js +0 -11
- /package/react/dist/{recipes → blocks}/install-command.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/install-command.js +0 -0
- /package/react/dist/{recipes → blocks}/market-row.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/market-row.js +0 -0
- /package/react/dist/{recipes → blocks}/marketing-hero.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/marketing-hero.js +0 -0
- /package/react/dist/{recipes → blocks}/swap/amount-card.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/swap/amount-card.js +0 -0
- /package/react/dist/{recipes → blocks}/swap/settings.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/swap/settings.js +0 -0
- /package/react/dist/{recipes → blocks}/trade-entry.d.ts +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AssetArtwork } from './asset-balance-row.js';
|
|
3
|
+
/** The promotion above the standings: a prize pool filling towards a goal, or a draw with a top prize. Every word is host text. */
|
|
4
|
+
export interface RewardPromo {
|
|
5
|
+
/** The small capitals line: Season 01. */
|
|
6
|
+
eyebrow: string;
|
|
7
|
+
/** A text link with a chevron on the trailing edge of the eyebrow: Rules. */
|
|
8
|
+
rules?: {
|
|
9
|
+
label: string;
|
|
10
|
+
onSelect: () => void;
|
|
11
|
+
};
|
|
12
|
+
/** The headline figure: the pool so far, or the top prize. `null` reads as unknown. */
|
|
13
|
+
amount: number | null;
|
|
14
|
+
/** Format of `amount` and `goal`. Defaults to whole US dollars. */
|
|
15
|
+
amountOptions?: Intl.NumberFormatOptions;
|
|
16
|
+
/** The amount the pool is filling towards. Draws the progress bar under the caption. */
|
|
17
|
+
goal?: number;
|
|
18
|
+
/** The line under the figure. A function receives the formatted goal: `goal => 'of ' + goal + ' prize pool'`. A string is drawn as given: top prize. */
|
|
19
|
+
caption?: string | ((goal: string) => string);
|
|
20
|
+
/** The lead of the explaining sentence, in the text colour: Top 100 traders split the pool. */
|
|
21
|
+
headline?: string;
|
|
22
|
+
/** Continues the sentence after the headline in the muted colour: Funded by builder fees on every trade. */
|
|
23
|
+
description?: string;
|
|
24
|
+
/** A full-width action under the description: Draws and winners. The host opens its own destination. */
|
|
25
|
+
action?: {
|
|
26
|
+
label: string;
|
|
27
|
+
onSelect: () => void;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** One trader in the standings. */
|
|
31
|
+
export interface RewardEntry {
|
|
32
|
+
id: string;
|
|
33
|
+
rank: number;
|
|
34
|
+
/** A short address, a handle, or the host's word for the viewer. */
|
|
35
|
+
name: string;
|
|
36
|
+
/** An image URL or a host element. Without one the first letters of the name are shown. */
|
|
37
|
+
avatar?: AssetArtwork;
|
|
38
|
+
/** Shows the verified mark after the name. */
|
|
39
|
+
verified?: boolean;
|
|
40
|
+
/** The line under the name: `$1,090,779 vol`. */
|
|
41
|
+
detail?: string;
|
|
42
|
+
/** Points or entries. `null` reads as unknown. */
|
|
43
|
+
score: number | null;
|
|
44
|
+
/** Marks the viewer's own row: the name and score take the action colour. */
|
|
45
|
+
you?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface RewardBlockProps {
|
|
48
|
+
/** Heading: Leaderboard. */
|
|
49
|
+
title: string;
|
|
50
|
+
promo?: RewardPromo;
|
|
51
|
+
/** A choice between standings, such as Upcoming draw and Top winners. `label` names the control. */
|
|
52
|
+
tabs?: {
|
|
53
|
+
label: string;
|
|
54
|
+
options: readonly {
|
|
55
|
+
value: string;
|
|
56
|
+
label: string;
|
|
57
|
+
}[];
|
|
58
|
+
value: string;
|
|
59
|
+
onValueChange: (value: string) => void;
|
|
60
|
+
};
|
|
61
|
+
/** The viewer's own standing, pinned above the list on a tinted row. */
|
|
62
|
+
you?: RewardEntry;
|
|
63
|
+
/** The column heading over the names: Top 25 by volume. */
|
|
64
|
+
listTitle?: string;
|
|
65
|
+
/** The column heading over the scores: Entries. */
|
|
66
|
+
scoreTitle?: string;
|
|
67
|
+
entries: readonly RewardEntry[];
|
|
68
|
+
/** Format of every score. Defaults to a whole number. */
|
|
69
|
+
scoreOptions?: Intl.NumberFormatOptions;
|
|
70
|
+
/** Words for the verified mark, read after the name. */
|
|
71
|
+
verifiedLabel?: string;
|
|
72
|
+
/** A line under the list: Entries are provisional until audited. */
|
|
73
|
+
footnote?: string;
|
|
74
|
+
/** Shows Back on the leading edge of the header. */
|
|
75
|
+
onBack?: () => void;
|
|
76
|
+
/** A control on the trailing edge of the header, usually an IconButton that shares. */
|
|
77
|
+
headerAction?: React.ReactNode;
|
|
78
|
+
testID?: string;
|
|
79
|
+
}
|
|
80
|
+
/** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
|
|
81
|
+
export declare function rewardProgress(amount: number | null | undefined, goal: number | null | undefined): number | null;
|
|
82
|
+
/** A competition as a screen: an optional promotion (a prize pool filling towards its goal, or a draw with its top prize), an optional choice of standings, the viewer's own standing pinned on a tinted row, and the ranked list. */
|
|
83
|
+
export declare function RewardBlock({ title, promo, tabs, you, listTitle, scoreTitle, entries, scoreOptions, verifiedLabel, footnote, onBack, headerAction, testID }: RewardBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Image, Pressable, View } from 'react-native';
|
|
3
|
+
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
4
|
+
import { withAlpha } from '@bloxwap/hig/tokens';
|
|
5
|
+
import { useColors, useFills, useHIG, useMessages } from './provider.js';
|
|
6
|
+
import { Surface, Text } from './surface.js';
|
|
7
|
+
import { IconButton } from './button.js';
|
|
8
|
+
import { SegmentedControl } from './radio-group.js';
|
|
9
|
+
import { ChevronIcon, SeverityIcon } from './icons.js';
|
|
10
|
+
import { AnimatedNumberReadout } from './animated-number.js';
|
|
11
|
+
import { formatNumberReadout } from './animated-number-model.js';
|
|
12
|
+
const wholeDollars = { style: 'currency', currency: 'USD', maximumFractionDigits: 0 };
|
|
13
|
+
const whole = { maximumFractionDigits: 0 };
|
|
14
|
+
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
15
|
+
const avatar = 40, space = ' ';
|
|
16
|
+
/** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
|
|
17
|
+
export function rewardProgress(amount, goal) {
|
|
18
|
+
return amount == null || goal == null || !Number.isFinite(amount) || !Number.isFinite(goal) || !(goal > 0) ? null : Math.min(1, Math.max(0, amount / goal));
|
|
19
|
+
}
|
|
20
|
+
/** A competition as a screen: an optional promotion (a prize pool filling towards its goal, or a draw with its top prize), an optional choice of standings, the viewer's own standing pinned on a tinted row, and the ranked list. */
|
|
21
|
+
export function RewardBlock({ title, promo, tabs, you, listTitle, scoreTitle, entries, scoreOptions = whole, verifiedLabel, footnote, onBack, headerAction, testID }) {
|
|
22
|
+
const colors = useColors(), fills = useFills(), t = useMessages(), { direction, locale, monoFontFamily } = useHIG();
|
|
23
|
+
const money = promo?.amountOptions ?? wholeDollars, reached = promo ? rewardProgress(promo.amount, promo.goal) : null;
|
|
24
|
+
const caption = typeof promo?.caption === 'function' ? promo.goal !== undefined ? promo.caption(formatNumber(promo.goal, locale, money)) : undefined : promo?.caption;
|
|
25
|
+
const caps = { fontFamily: monoFontFamily, fontSize: 12, lineHeight: 16, letterSpacing: 1.5, textTransform: 'uppercase' };
|
|
26
|
+
const standing = (entry, id, style) => {
|
|
27
|
+
const mine = !!entry.you, reading = [String(entry.rank), entry.name, entry.verified && verifiedLabel ? verifiedLabel : null, entry.detail, formatNumberReadout(entry.score, locale, scoreOptions).text].filter(Boolean).join(', ');
|
|
28
|
+
const disc = { width: avatar, height: avatar, borderRadius: avatar / 2, backgroundColor: fills.raised, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' };
|
|
29
|
+
return _jsxs(View, { testID: id, accessible: true, accessibilityLabel: reading, style: { direction, flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 64, paddingVertical: 8, paddingHorizontal: 20, backgroundColor: fills.well, ...style }, children: [_jsx(Text, { ...hidden, style: { minWidth: 24, fontFamily: monoFontFamily, fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.muted }, children: entry.rank }), _jsx(View, { ...hidden, children: typeof entry.avatar === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: entry.avatar }, style: disc }) : _jsx(View, { style: disc, children: entry.avatar ?? _jsx(Text, { maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: entry.name.slice(0, 2) }) }) }), _jsxs(View, { ...hidden, style: { flex: 1, flexShrink: 1, minWidth: 0 }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 6 }, children: [_jsx(Text, { testID: `${id}-name`, numberOfLines: 1, style: { flexShrink: 1, fontFamily: monoFontFamily, fontSize: 16, lineHeight: 24, fontWeight: '600', color: mine ? colors.action : colors.text }, children: entry.name }), entry.verified ? _jsx(View, { testID: `${id}-verified`, style: { transform: [{ scale: 0.8 }] }, children: _jsx(SeverityIcon, { kind: 'success', color: colors.warning }) }) : null] }), entry.detail ? _jsx(Text, { numberOfLines: 1, style: { fontFamily: monoFontFamily, fontSize: 14, lineHeight: 20, color: colors.muted }, children: entry.detail }) : null] }), _jsx(View, { ...hidden, children: _jsx(AnimatedNumberReadout, { value: entry.score, options: scoreOptions, tone: mine ? 'positive' : 'text', testID: `${id}-score`, style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) })] }, entry.id);
|
|
30
|
+
};
|
|
31
|
+
// Rows are built here so their test ids are code, not JSX text.
|
|
32
|
+
const pinned = you ? standing({ ...you, you: true }, 'reward-you', { marginTop: 16, borderRadius: 20, backgroundColor: withAlpha(colors.action, 0.12) }) : null;
|
|
33
|
+
const rows = entries.map(entry => standing(entry, `reward-row-${entry.id}`));
|
|
34
|
+
return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [_jsxs(View, { testID: 'reward-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: 'reward-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'reward-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 })] }), promo ? _jsxs(Surface, { testID: 'reward-promo', style: { gap: 12, marginTop: 16 }, children: [_jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12 }, children: [_jsx(Text, { testID: 'reward-eyebrow', style: { ...caps, flexShrink: 1, color: colors.muted }, children: promo.eyebrow }), promo.rules ? _jsxs(Pressable, { testID: 'reward-rules', accessibilityRole: 'button', hitSlop: 12, onPress: promo.rules.onSelect, style: ({ pressed }) => ({ flexDirection: 'row', alignItems: 'center', gap: 4, opacity: pressed ? 0.6 : 1 }), children: [_jsx(Text, { style: { fontSize: 16, lineHeight: 24, fontWeight: '500', color: colors.muted }, children: promo.rules.label }), _jsx(View, { ...hidden, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] }) : null] }), _jsxs(View, { testID: 'reward-amount', accessible: true, accessibilityLabel: [formatNumberReadout(promo.amount, locale, money).text, caption].filter(Boolean).join(' '), style: { gap: 4 }, children: [_jsx(View, { ...hidden, style: { alignItems: 'flex-start' }, children: _jsx(AnimatedNumberReadout, { value: promo.amount, options: money, tone: 'positive', style: { fontSize: 44, lineHeight: 50, fontWeight: '700', letterSpacing: -0.9 } }) }), caption ? _jsx(Text, { ...hidden, testID: 'reward-caption', style: { fontFamily: monoFontFamily, fontSize: 15, lineHeight: 22, color: colors.muted }, children: caption }) : null] }), promo.goal !== undefined ? _jsx(View, { ...hidden, testID: 'reward-track', style: { direction, flexDirection: 'row', height: 4, borderRadius: 2, backgroundColor: fills.raised, overflow: 'hidden' }, children: _jsx(View, { testID: 'reward-fill', style: { width: `${(reached ?? 0) * 100}%`, minWidth: 8, borderRadius: 2, backgroundColor: colors.action } }) }) : null, promo.headline || promo.description ? _jsxs(Text, { testID: 'reward-summary', style: { fontSize: 16, lineHeight: 24, color: colors.muted }, children: [promo.headline ? _jsx(Text, { style: { fontWeight: '600', color: colors.text }, children: promo.headline }) : null, promo.headline && promo.description ? space : null, promo.description] }) : null, promo.action ? _jsxs(Pressable, { testID: 'reward-action', accessibilityRole: 'button', accessibilityLabel: promo.action.label, onPress: promo.action.onSelect, style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 44, marginTop: 4, marginBottom: -8, paddingTop: 12, borderTopWidth: 1, borderTopColor: fills.raised }, children: [_jsx(Text, { ...hidden, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '500', color: colors.muted }, children: promo.action.label }), _jsx(View, { ...hidden, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] }) : null] }) : null, tabs ? _jsx(View, { testID: 'reward-tabs', style: { marginTop: 16 }, children: _jsx(SegmentedControl, { label: tabs.label, options: tabs.options, value: tabs.value, onValueChange: tabs.onValueChange }) }) : null, pinned, entries.length > 0 || listTitle || scoreTitle ? _jsxs(View, { testID: 'reward-list', style: { gap: 8, marginTop: 16 }, children: [listTitle || scoreTitle ? _jsxs(View, { style: { direction, flexDirection: 'row', justifyContent: 'space-between', gap: 12, paddingHorizontal: 4 }, children: [_jsx(Text, { testID: 'reward-list-title', style: { ...caps, flexShrink: 1, color: colors.muted }, children: listTitle }), _jsx(Text, { testID: 'reward-score-title', style: { ...caps, flexShrink: 1, color: colors.muted, textAlign: 'right' }, children: scoreTitle })] }) : null, entries.length > 0 ? _jsx(View, { testID: 'reward-rows', style: { gap: 2, borderRadius: 20, overflow: 'hidden' }, children: rows }) : null] }) : null, footnote ? _jsx(Text, { testID: 'reward-footnote', style: { fontSize: 14, lineHeight: 21, color: colors.muted, marginTop: 16, paddingHorizontal: 4 }, children: footnote }) : null] });
|
|
35
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** The header of a block that is its own screen: Back on the leading edge, the title centred, an optional control on the trailing edge. */
|
|
3
|
+
export declare function SettingHeader({ title, onBack, action, testID }: {
|
|
4
|
+
title: string;
|
|
5
|
+
onBack?: () => void;
|
|
6
|
+
action?: React.ReactNode;
|
|
7
|
+
testID: string;
|
|
8
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { useColors, useHIG, useMessages } from './provider.js';
|
|
4
|
+
import { Text } from './surface.js';
|
|
5
|
+
import { IconButton } from './button.js';
|
|
6
|
+
import { ChevronIcon } from './icons.js';
|
|
7
|
+
/** The header of a block that is its own screen: Back on the leading edge, the title centred, an optional control on the trailing edge. */
|
|
8
|
+
export function SettingHeader({ title, onBack, action, testID }) {
|
|
9
|
+
const colors = useColors(), t = useMessages(), { direction } = useHIG();
|
|
10
|
+
return _jsxs(View, { testID: `${testID}-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: `${testID}-back`, onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: `${testID}-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: action })] });
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface SettingSwitchProps {
|
|
3
|
+
label: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
checked: boolean;
|
|
6
|
+
onCheckedChange: (checked: boolean) => void;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
testID?: string;
|
|
9
|
+
}
|
|
10
|
+
/** One setting as a switch: the label over an optional description on the leading edge, the track on the trailing edge. The whole row is the switch; the label names it and the description is its hint. */
|
|
11
|
+
export declare function SettingSwitch({ label, description, checked, onCheckedChange, disabled, testID }: SettingSwitchProps): React.JSX.Element;
|
|
12
|
+
/** The card a setting sits in. Inside a list the cards share one rounded container, so they drop their own radius. */
|
|
13
|
+
export declare function SettingCard({ children, joined, testID }: React.PropsWithChildren<{
|
|
14
|
+
joined?: boolean;
|
|
15
|
+
testID?: string;
|
|
16
|
+
}>): React.JSX.Element;
|
|
17
|
+
/** The shared header of a settings screen: Back on the leading edge, the title centred, a host control on the trailing edge. */
|
|
18
|
+
export { SettingHeader } from './setting-header.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { useColors, useFills, useHIG } from './provider.js';
|
|
4
|
+
import { Text } from './surface.js';
|
|
5
|
+
import { SwitchRow } from './switch-row.js';
|
|
6
|
+
/** One setting as a switch: the label over an optional description on the leading edge, the track on the trailing edge. The whole row is the switch; the label names it and the description is its hint. */
|
|
7
|
+
export function SettingSwitch({ label, description, checked, onCheckedChange, disabled, testID }) {
|
|
8
|
+
const colors = useColors(), fills = useFills(), { direction } = useHIG();
|
|
9
|
+
return _jsx(SwitchRow, { testID: testID, label: label, accessibilityHint: description, checked: checked, disabled: disabled, onCheckedChange: onCheckedChange, style: { minHeight: 32, opacity: disabled ? 0.5 : 1 }, children: _jsxs(View, { style: { direction, flex: 1, flexDirection: 'row', alignItems: 'flex-start', gap: 12 }, children: [_jsxs(View, { style: { flex: 1, minWidth: 0, gap: 2 }, children: [_jsx(Text, { style: { fontSize: 16, lineHeight: 24, color: colors.text }, children: label }), description ? _jsx(Text, { style: { fontSize: 14, lineHeight: 21, color: colors.muted }, children: description }) : null] }), _jsx(View, { testID: testID ? `${testID}-track` : undefined, style: { width: 40, height: 24, borderRadius: 12, padding: 3, backgroundColor: checked ? colors.action : fills.raised, alignItems: checked ? 'flex-end' : 'flex-start' }, children: _jsx(View, { style: { width: 18, height: 18, borderRadius: 9, backgroundColor: checked ? colors.onAction : colors.text } }) })] }) });
|
|
10
|
+
}
|
|
11
|
+
/** The card a setting sits in. Inside a list the cards share one rounded container, so they drop their own radius. */
|
|
12
|
+
export function SettingCard({ children, joined, testID }) {
|
|
13
|
+
const fills = useFills();
|
|
14
|
+
return _jsx(View, { testID: testID, style: { gap: 12, paddingVertical: 12, paddingHorizontal: 20, borderRadius: joined ? 0 : 20, backgroundColor: fills.well }, children: children });
|
|
15
|
+
}
|
|
16
|
+
/** The shared header of a settings screen: Back on the leading edge, the title centred, a host control on the trailing edge. */
|
|
17
|
+
export { SettingHeader } from './setting-header.js';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** One signal the viewer can turn on. */
|
|
3
|
+
export interface SignalsItem {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
checked: boolean;
|
|
8
|
+
onCheckedChange: (checked: boolean) => void;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** A family of signals under one heading: Trend, Swing. Every word is host text. */
|
|
12
|
+
export interface SignalsGroup {
|
|
13
|
+
id: string;
|
|
14
|
+
title: string;
|
|
15
|
+
/** Shows the verified mark after the title. */
|
|
16
|
+
verified?: boolean;
|
|
17
|
+
/** A small pill on the trailing edge of the heading: How it works. The host opens its own explanation. */
|
|
18
|
+
help?: {
|
|
19
|
+
label: string;
|
|
20
|
+
onSelect: () => void;
|
|
21
|
+
};
|
|
22
|
+
items: readonly SignalsItem[];
|
|
23
|
+
}
|
|
24
|
+
export interface SignalsBlockProps {
|
|
25
|
+
/** Heading: Signals. */
|
|
26
|
+
title: string;
|
|
27
|
+
groups: readonly SignalsGroup[];
|
|
28
|
+
/** Words for the verified mark, read after the group title. */
|
|
29
|
+
verifiedLabel?: string;
|
|
30
|
+
/** Shows Back on the leading edge of the header. */
|
|
31
|
+
onBack?: () => void;
|
|
32
|
+
/** A control on the trailing edge of the header, usually an IconButton. */
|
|
33
|
+
headerAction?: React.ReactNode;
|
|
34
|
+
testID?: string;
|
|
35
|
+
}
|
|
36
|
+
/** The signals the viewer receives, as a screen, in groups: each group has a heading with an optional verified mark and a small help pill, and its signals as switches with a line of explanation, sharing one rounded container. */
|
|
37
|
+
export declare function SignalsBlock({ title, groups, verifiedLabel, onBack, headerAction, testID }: SignalsBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { useColors, useHIG } from './provider.js';
|
|
4
|
+
import { Text } from './surface.js';
|
|
5
|
+
import { SwapCapsule } from './swap-parts.js';
|
|
6
|
+
import { SeverityIcon } from './icons.js';
|
|
7
|
+
import { SettingCard, SettingHeader, SettingSwitch } from './setting-switch.js';
|
|
8
|
+
/** The signals the viewer receives, as a screen, in groups: each group has a heading with an optional verified mark and a small help pill, and its signals as switches with a line of explanation, sharing one rounded container. */
|
|
9
|
+
export function SignalsBlock({ title, groups, verifiedLabel, onBack, headerAction, testID }) {
|
|
10
|
+
const colors = useColors(), { direction } = useHIG();
|
|
11
|
+
const sections = groups.map(group => {
|
|
12
|
+
const id = `signals-${group.id}`;
|
|
13
|
+
return _jsxs(View, { testID: id, style: { gap: 8, marginTop: 16 }, children: [_jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 44, paddingStart: 4 }, children: [_jsxs(View, { accessible: true, accessibilityRole: 'header', accessibilityLabel: [group.title, group.verified && verifiedLabel ? verifiedLabel : null].filter(Boolean).join(', '), testID: `${id}-title`, style: { flexDirection: 'row', alignItems: 'center', gap: 6, flexShrink: 1 }, children: [_jsx(Text, { accessible: false, numberOfLines: 1, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '500', color: colors.muted }, children: group.title }), group.verified ? _jsx(View, { testID: `${id}-verified`, style: { transform: [{ scale: 0.8 }] }, children: _jsx(SeverityIcon, { kind: 'success', color: colors.warning }) }) : null] }), group.help ? _jsx(SwapCapsule, { testID: `${id}-help`, onPress: group.help.onSelect, children: _jsx(Text, { style: { fontSize: 14, lineHeight: 20, fontWeight: '500', color: colors.muted }, children: group.help.label }) }) : null] }), group.items.length > 0 ? _jsx(View, { testID: `${id}-items`, style: { gap: 2, borderRadius: 20, overflow: 'hidden' }, children: group.items.map(item => _jsx(SettingCard, { joined: true, testID: `${id}-${item.id}`, children: _jsx(SettingSwitch, { testID: `${id}-${item.id}-switch`, label: item.label, description: item.description, checked: item.checked, disabled: item.disabled, onCheckedChange: item.onCheckedChange }) }, item.id)) }) : null] }, group.id);
|
|
14
|
+
});
|
|
15
|
+
return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [_jsx(SettingHeader, { testID: 'signals', title: title, onBack: onBack, action: headerAction }), sections] });
|
|
16
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** A volume as a few fixed steps. `value` and `options` are fractions: 0.25 reads 25%. */
|
|
3
|
+
export interface SoundVolume {
|
|
4
|
+
/** Names the steps and is drawn above them: Volume. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Defaults to 25%, 50%, 75% and 100%. */
|
|
7
|
+
options?: readonly number[];
|
|
8
|
+
value: number;
|
|
9
|
+
onValueChange: (value: number) => void;
|
|
10
|
+
}
|
|
11
|
+
/** One feedback channel: sound effects, the microphone, haptics, the flash. Every word is host text. */
|
|
12
|
+
export interface SoundSection {
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
checked: boolean;
|
|
17
|
+
onCheckedChange: (checked: boolean) => void;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** The device in use, under the switch: iPhone Microphone. */
|
|
20
|
+
source?: string;
|
|
21
|
+
/** A live input level from 0 to 1, drawn as a meter. `null` draws an empty meter. */
|
|
22
|
+
level?: number | null;
|
|
23
|
+
volume?: SoundVolume;
|
|
24
|
+
}
|
|
25
|
+
export interface SoundHapticsBlockProps {
|
|
26
|
+
/** Heading: Sound & Haptics. */
|
|
27
|
+
title: string;
|
|
28
|
+
/** One card each, in order. A section's source, meter and volume show only while it is on. */
|
|
29
|
+
sections: readonly SoundSection[];
|
|
30
|
+
/** Shows Back on the leading edge of the header. */
|
|
31
|
+
onBack?: () => void;
|
|
32
|
+
/** A control on the trailing edge of the header, usually an IconButton. */
|
|
33
|
+
headerAction?: React.ReactNode;
|
|
34
|
+
testID?: string;
|
|
35
|
+
}
|
|
36
|
+
/** The share of the meter filled, from 0 to 1. Unknown and out-of-range levels are clamped. */
|
|
37
|
+
export declare const soundLevel: (level: number | null | undefined) => number;
|
|
38
|
+
/** The settings for what the app plays and feels like, as a screen: each channel is a card with a switch, and a channel that is on can show the device it uses, a live input meter and its volume as fixed steps. */
|
|
39
|
+
export declare function SoundHapticsBlock({ title, sections, onBack, headerAction, testID }: SoundHapticsBlockProps): 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 { formatNumber } from '@bloxwap/hig/contracts';
|
|
4
|
+
import { useColors, useFills, useHIG } from './provider.js';
|
|
5
|
+
import { Text } from './surface.js';
|
|
6
|
+
import { Button } from './button.js';
|
|
7
|
+
import { SettingCard, SettingHeader, SettingSwitch } from './setting-switch.js';
|
|
8
|
+
const steps = [0.25, 0.5, 0.75, 1], percent = { style: 'percent', maximumFractionDigits: 0 };
|
|
9
|
+
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
10
|
+
/** The share of the meter filled, from 0 to 1. Unknown and out-of-range levels are clamped. */
|
|
11
|
+
export const soundLevel = (level) => level == null || !Number.isFinite(level) ? 0 : Math.min(1, Math.max(0, level));
|
|
12
|
+
/** The settings for what the app plays and feels like, as a screen: each channel is a card with a switch, and a channel that is on can show the device it uses, a live input meter and its volume as fixed steps. */
|
|
13
|
+
export function SoundHapticsBlock({ title, sections, onBack, headerAction, testID }) {
|
|
14
|
+
const colors = useColors(), fills = useFills(), { direction, locale } = useHIG();
|
|
15
|
+
const caption = { fontSize: 14, lineHeight: 21, color: colors.muted };
|
|
16
|
+
const cards = sections.map(section => {
|
|
17
|
+
const { source, level, volume } = section, open = section.checked && (!!source || level !== undefined || !!volume), id = `sound-${section.id}`;
|
|
18
|
+
return _jsxs(SettingCard, { testID: id, children: [_jsx(SettingSwitch, { testID: `${id}-switch`, label: section.label, description: section.description, checked: section.checked, disabled: section.disabled, onCheckedChange: section.onCheckedChange }), open ? _jsxs(View, { testID: `${id}-body`, style: { gap: 8 }, children: [source ? _jsx(Text, { testID: `${id}-source`, style: caption, children: source }) : null, level !== undefined ? _jsx(View, { ...hidden, testID: `${id}-meter`, style: { direction, flexDirection: 'row', height: 4, borderRadius: 2, backgroundColor: fills.raised, overflow: 'hidden' }, children: _jsx(View, { testID: `${id}-level`, style: { width: `${soundLevel(level) * 100}%`, borderRadius: 2, backgroundColor: colors.action } }) }) : null, volume ? _jsxs(View, { testID: `${id}-volume`, accessibilityRole: 'radiogroup', accessibilityLabel: volume.label, style: { gap: 8 }, children: [_jsx(Text, { ...hidden, style: caption, children: volume.label }), _jsx(View, { style: { direction, flexDirection: 'row', gap: 8 }, children: (volume.options ?? steps).map(option => _jsx(Button, { testID: `${id}-volume-${option}`, intent: option === volume.value ? 'primary' : 'secondary', accessibilityState: { selected: option === volume.value }, disabled: section.disabled, onPress: () => volume.onValueChange(option), style: { flex: 1, alignSelf: 'auto', paddingHorizontal: 8 }, children: formatNumber(option, locale, percent) }, option)) })] }) : null] }) : null] }, section.id);
|
|
19
|
+
});
|
|
20
|
+
return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [_jsx(SettingHeader, { testID: 'sound', title: title, onBack: onBack, action: headerAction }), sections.length > 0 ? _jsx(View, { testID: 'sound-sections', style: { gap: 8, marginTop: 16 }, children: cards }) : null] });
|
|
21
|
+
}
|
|
@@ -34,7 +34,7 @@ export interface SwapReceive {
|
|
|
34
34
|
qr?: React.ReactNode; /** Host clipboard adapter. When set, the whole view copies the address. */
|
|
35
35
|
onCopy?: () => Promise<void> | void;
|
|
36
36
|
}
|
|
37
|
-
export interface
|
|
37
|
+
export interface SwapPanelBlockProps {
|
|
38
38
|
/** Catalog for the To side, and for the From side unless `fromTokens` is given. */
|
|
39
39
|
tokens: readonly SwapToken[];
|
|
40
40
|
/** Assets offered on the From side, typically the connected wallet's holdings. */
|
|
@@ -137,4 +137,8 @@ export interface SwapPanelProps {
|
|
|
137
137
|
* or token units through the keypad, token pickers, settings, and one action that names itself from the chosen pair.
|
|
138
138
|
* Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
|
|
139
139
|
*/
|
|
140
|
-
export declare function
|
|
140
|
+
export declare function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains, hotTokenIds, from: fromProp, to: toProp, defaultFrom, defaultTo, onFromChange, onToChange, amount, onAmountChange, received, fee, fees, quoteLoading, slippage, onSlippageChange, denomination, onDenominationChange, wallet, onConnect, onDisconnect, recipient, onRecipientChange, onScanRecipient, receive, receiving, onReceivingChange, onSubmit, submitting, onReset, keypad, destination, details, note, noteTone, title, onBack, controls, actionIcon, lockFrom, lockTo, actionLabel, actionDisabled, actionStatus, actionIntent, limitToBalance, banner, footer, oneWay: oneWayProp, denominationSwitch, settings, view: viewProp, onViewChange, style }: SwapPanelBlockProps): React.JSX.Element;
|
|
141
|
+
/** @deprecated Renamed `SwapPanelBlock`. The old name keeps working until the next major release. */
|
|
142
|
+
export declare const SwapPanel: typeof SwapPanelBlock;
|
|
143
|
+
/** @deprecated Renamed `SwapPanelBlockProps`. */
|
|
144
|
+
export type SwapPanelProps = SwapPanelBlockProps;
|
|
@@ -20,7 +20,7 @@ export { SwapHostContext } from './swap-parts.js';
|
|
|
20
20
|
* or token units through the keypad, token pickers, settings, and one action that names itself from the chosen pair.
|
|
21
21
|
* Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
|
|
22
22
|
*/
|
|
23
|
-
export function
|
|
23
|
+
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
24
|
const env = useHIG();
|
|
25
25
|
const { locale, direction } = env;
|
|
26
26
|
const colors = useColors();
|
|
@@ -140,7 +140,7 @@ export function SwapPanel({ tokens, fromTokens, fromTokensLoading, chains, hotTo
|
|
|
140
140
|
};
|
|
141
141
|
const fromCard = card('from'), toCard = fixedCard() ?? card('to');
|
|
142
142
|
const tone = noteTone === 'warning' ? colors.warning : noteTone === 'negative' ? colors.negative : null;
|
|
143
|
-
const main = _jsxs(View, { testID: 'swap-view-main', children: [title ? _jsx(View, { style: { marginBottom: 12 }, children: _jsx(SwapHeader, { title: title, onBack: onBack }) }) : null, banner ? _jsx(View, { testID: 'swap-banner', style: { marginBottom: 8 }, children: banner }) : null, fromCard, _jsx(View, { style: { height: 8, zIndex: 1, alignItems: 'center' }, children: _jsx(View, { style: { position: 'absolute', top: -15, width: 38, height: 38, borderRadius: 19, backgroundColor: colors.background, alignItems: 'center', justifyContent: 'center' }, children: oneWay ? _jsx(View, { testID: 'swap-one-way', style: { width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center', backgroundColor: colors.nested }, children: _jsx(DownIcon, { color: colors.muted }) }) : _jsx(Pressable, { accessibilityRole: 'button', accessibilityLabel: t.swapFlip, accessibilityState: { disabled: !from || !to }, disabled: !from || !to, testID: 'swap-flip', onPress: flip, hitSlop: 6, style: ({ pressed }) => ({ width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center', backgroundColor: !from || !to ? colors.surface : colors.nested, opacity: pressed ? 0.85 : 1 }), children: _jsx(FlipIcon, { color: !from || !to ? colors.faint : colors.muted }) }) }) }), toCard, note ? _jsx(View, { testID: 'swap-note', style: tone ? { marginTop: 8, paddingVertical: 12, paddingHorizontal: 16, borderRadius: 16, backgroundColor: withAlpha(tone, 0.
|
|
143
|
+
const main = _jsxs(View, { testID: 'swap-view-main', children: [title ? _jsx(View, { style: { marginBottom: 12 }, children: _jsx(SwapHeader, { title: title, onBack: onBack }) }) : null, banner ? _jsx(View, { testID: 'swap-banner', style: { marginBottom: 8 }, children: banner }) : null, fromCard, _jsx(View, { style: { height: 8, zIndex: 1, alignItems: 'center' }, children: _jsx(View, { style: { position: 'absolute', top: -15, width: 38, height: 38, borderRadius: 19, backgroundColor: colors.background, alignItems: 'center', justifyContent: 'center' }, children: oneWay ? _jsx(View, { testID: 'swap-one-way', style: { width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center', backgroundColor: colors.nested }, children: _jsx(DownIcon, { color: colors.muted }) }) : _jsx(Pressable, { accessibilityRole: 'button', accessibilityLabel: t.swapFlip, accessibilityState: { disabled: !from || !to }, disabled: !from || !to, testID: 'swap-flip', onPress: flip, hitSlop: 6, style: ({ pressed }) => ({ width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center', backgroundColor: !from || !to ? colors.surface : colors.nested, opacity: pressed ? 0.85 : 1 }), children: _jsx(FlipIcon, { color: !from || !to ? colors.faint : colors.muted }) }) }) }), toCard, note ? _jsx(View, { testID: 'swap-note', style: tone ? { marginTop: 8, paddingVertical: 12, paddingHorizontal: 16, borderRadius: 16, backgroundColor: withAlpha(tone, 0.1) } : { marginTop: 8, paddingHorizontal: 4 }, children: _jsx(Text, { style: { fontSize: 14, lineHeight: 21, color: tone ?? colors.muted }, children: note }) }) : null, !showReceive && keypad !== 'never' ? _jsx(SwapKeypad, { onKey: press, label: t.swapKeypad, deleteLabel: t.swapDelete }) : null, _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8, marginTop: 16 }, children: [controls ? _jsx(IconButton, { intent: 'secondary', label: t.swapSettings, suppressFeedback: true, testID: 'swap-settings-button', onPress: () => show('settings'), children: _jsx(MenuIcon, { color: colors.text }) }) : null, _jsxs(Button, { intent: actionIntent, busy: submitting, disabled: !showReceive && !ready, testID: 'swap-action', onPress: submit, style: { flex: 1, alignSelf: 'auto' }, children: [actionIcon ? _jsx(View, { testID: 'swap-action-icon', accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: actionIcon }, 'icon') : null, actionText] }), controls ? _jsx(IconButton, { intent: 'secondary', label: t.swapReset, disabled: pristine || submitting, testID: 'swap-reset', onPress: reset, children: _jsx(ResetIcon, { color: colors.text }) }) : null] }), notice ? _jsx(View, { style: { marginTop: 8, alignItems: 'center' }, children: _jsx(Toast, { notices: [notice], onDismiss: dismissNotice }) }) : null, footer ? _jsx(View, { testID: 'swap-footer', style: { marginTop: 16 }, children: footer }) : null] });
|
|
144
144
|
const body = view === 'main' ? main
|
|
145
145
|
: view === 'from' ? _jsx(SwapPicker, { side: view, onBack: back, tokens: fromTokens ?? tokens, loading: fromTokensLoading, chains: chainList, hotTokenIds: hotTokenIds, selected: from, onSelect: setFrom, wallet: wallet, onConnect: onConnect, onDisconnect: onDisconnect, receiving: isReceiving, onReceivingChange: receive ? setReceiving : undefined })
|
|
146
146
|
: view === 'to' ? _jsx(SwapPicker, { side: view, onBack: back, tokens: tokens, chains: chainList, hotTokenIds: hotTokenIds, selected: to, onSelect: setTo, wallet: wallet, recipient: recipient, onRecipientChange: onRecipientChange, onScanRecipient: onScanRecipient })
|
|
@@ -183,3 +183,5 @@ function SwapStage({ view, animateHeight, children }) {
|
|
|
183
183
|
const fitted = sizing && sized;
|
|
184
184
|
return _jsx(Animated.View, { testID: 'swap-stage', style: fitted ? { height, overflow: 'hidden' } : undefined, children: _jsx(Animated.View, { onLayout: onLayout, style: [fitted ? { position: 'absolute', left: 0, right: 0, top: 0 } : null, { opacity: slide, transform: [{ translateX: slide.interpolate({ inputRange: [0, 1], outputRange: [travel.current * 48, 0] }) }] }], children: children }) });
|
|
185
185
|
}
|
|
186
|
+
/** @deprecated Renamed `SwapPanelBlock`. The old name keeps working until the next major release. */
|
|
187
|
+
export const SwapPanel = SwapPanelBlock;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type
|
|
3
|
-
export interface SwapSheetProps extends
|
|
2
|
+
import { type SwapPanelBlockProps } from './swap-panel-block.js';
|
|
3
|
+
export interface SwapSheetProps extends SwapPanelBlockProps {
|
|
4
4
|
open: boolean;
|
|
5
5
|
onOpenChange: (open: boolean) => void;
|
|
6
6
|
/** Accessible name of the sheet. */
|
|
7
7
|
title: string;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* SwapPanelBlock presented in the gesture sheet. Pickers and settings push inside the same sheet, which resizes to the view
|
|
11
11
|
* on show. A back press or a dismiss gesture pops a pushed view first and closes the sheet only from the main form;
|
|
12
|
-
* closing always returns to the main form. Needs the optional gesture-sheet backend, which `
|
|
12
|
+
* closing always returns to the main form. Needs the optional gesture-sheet backend, which `blocks` does not load.
|
|
13
13
|
*/
|
|
14
14
|
export declare function SwapSheet({ open, onOpenChange, title, view: viewProp, onViewChange, style, ...panel }: SwapSheetProps): React.JSX.Element;
|
|
@@ -2,11 +2,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { BottomSheetFlatList } from '@gorhom/bottom-sheet';
|
|
4
4
|
import { GestureSheet } from './gesture-sheet.js';
|
|
5
|
-
import { SwapHostContext,
|
|
5
|
+
import { SwapHostContext, SwapPanelBlock, swapParentView } from './swap-panel-block.js';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* SwapPanelBlock presented in the gesture sheet. Pickers and settings push inside the same sheet, which resizes to the view
|
|
8
8
|
* on show. A back press or a dismiss gesture pops a pushed view first and closes the sheet only from the main form;
|
|
9
|
-
* closing always returns to the main form. Needs the optional gesture-sheet backend, which `
|
|
9
|
+
* closing always returns to the main form. Needs the optional gesture-sheet backend, which `blocks` does not load.
|
|
10
10
|
*/
|
|
11
11
|
export function SwapSheet({ open, onOpenChange, title, view: viewProp, onViewChange, style, ...panel }) {
|
|
12
12
|
const [ownView, keepView] = useState('main');
|
|
@@ -22,5 +22,5 @@ export function SwapSheet({ open, onOpenChange, title, view: viewProp, onViewCha
|
|
|
22
22
|
return false; show(swapParentView(view)); return true; };
|
|
23
23
|
return _jsx(GestureSheet, { open: open, onOpenChange: next => { if (!next && leave())
|
|
24
24
|
return; onOpenChange(next); }, title: title, contentMode: 'custom', enableDynamicSizing: true, keyboardBehavior: 'interactive', onHardwareBackPress: () => { if (!leave())
|
|
25
|
-
onOpenChange(false); return true; }, children: _jsx(SwapHostContext.Provider, { value: host, children: _jsx(
|
|
25
|
+
onOpenChange(false); return true; }, children: _jsx(SwapHostContext.Provider, { value: host, children: _jsx(SwapPanelBlock, { ...panel, view: view, onViewChange: show, style: [{ paddingHorizontal: 12, paddingBottom: 16 }, style] }) }) });
|
|
26
26
|
}
|
|
@@ -20,7 +20,7 @@ export interface SwapPickerProps {
|
|
|
20
20
|
onRecipientChange?: (address: string) => void;
|
|
21
21
|
onScanRecipient?: () => void;
|
|
22
22
|
}
|
|
23
|
-
/** The panel's pushed picker view: the sub-view header over the From or To picker
|
|
23
|
+
/** The panel's pushed picker view: the sub-view header over the From or To picker block. Choosing a token pops back; the Generate address switch does not. */
|
|
24
24
|
export declare function SwapPicker({ side, onBack, selected, onSelect, wallet, onConnect, onDisconnect, receiving, onReceivingChange, recipient, onRecipientChange, onScanRecipient, ...list }: SwapPickerProps): React.JSX.Element;
|
|
25
25
|
export type SwapSettingsView = 'settings' | 'slippage' | 'fees';
|
|
26
26
|
export interface SwapSettingsProps {
|
|
@@ -9,15 +9,15 @@ import { SegmentedControl } from './radio-group.js';
|
|
|
9
9
|
import { ChevronIcon } from './icons.js';
|
|
10
10
|
import { AnimatedNumberReadout } from './animated-number.js';
|
|
11
11
|
import { SwapSubview } from './swap-parts.js';
|
|
12
|
-
import {
|
|
12
|
+
import { FromPickerBlock, ToPickerBlock } from './pickers.js';
|
|
13
13
|
import { formatPercent, shortAddress, slippagePresets } from './swap-shared.js';
|
|
14
|
-
/** The panel's pushed picker view: the sub-view header over the From or To picker
|
|
14
|
+
/** The panel's pushed picker view: the sub-view header over the From or To picker block. Choosing a token pops back; the Generate address switch does not. */
|
|
15
15
|
export function SwapPicker({ side, onBack, selected, onSelect, wallet, onConnect, onDisconnect, receiving, onReceivingChange, recipient, onRecipientChange, onScanRecipient, ...list }) {
|
|
16
16
|
const t = useMessages();
|
|
17
17
|
const choose = (token) => { onSelect(token); onBack(); };
|
|
18
18
|
return _jsx(SwapSubview, { title: side === 'from' ? t.swapFrom : t.swapTo, onBack: onBack, testID: `swap-picker-${side}`, children: side === 'from'
|
|
19
|
-
? _jsx(
|
|
20
|
-
: _jsx(
|
|
19
|
+
? _jsx(FromPickerBlock, { ...list, selected: selected, onSelect: choose, wallet: wallet ?? { connected: false }, onConnect: onConnect, onDisconnect: onDisconnect, generateAddress: !!receiving, onGenerateAddressChange: onReceivingChange })
|
|
20
|
+
: _jsx(ToPickerBlock, { ...list, selected: selected, onSelect: choose, address: recipient, onAddressChange: onRecipientChange, addressPlaceholder: wallet?.address ? shortAddress(wallet.address) : undefined, onScan: onScanRecipient }) });
|
|
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 }) {
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** What the target does: close in profit, or cap the loss. */
|
|
3
|
+
export type TargetKind = 'take-profit' | 'stop-loss';
|
|
4
|
+
/** How the target is expressed: profit or loss in dollars, a price, or a share of the position. */
|
|
5
|
+
export type TargetUnit = 'dollar' | 'price' | 'percent';
|
|
6
|
+
/** The three prices on the bar. */
|
|
7
|
+
export type TargetPrice = 'entry' | 'trigger';
|
|
8
|
+
/** Every trading word of the block. HIG's built-in strings hold no trading terms, so the host supplies them, translated; only Cancel has a built-in default. */
|
|
9
|
+
export interface TargetBlockLabels {
|
|
10
|
+
/** Heading: Take Profit, Stop Loss. */
|
|
11
|
+
title: string;
|
|
12
|
+
/** The confirming action: Set Take Profit. */
|
|
13
|
+
submit: string;
|
|
14
|
+
/** Defaults to the built-in Cancel. */
|
|
15
|
+
cancel?: string;
|
|
16
|
+
entry: string;
|
|
17
|
+
/** The price the order triggers at: If triggered. */
|
|
18
|
+
trigger: string;
|
|
19
|
+
/** Name of the unit control. */
|
|
20
|
+
unit: string;
|
|
21
|
+
units: Record<TargetUnit, string>;
|
|
22
|
+
/** The row that opens the host's own entry: Custom. */
|
|
23
|
+
custom: string;
|
|
24
|
+
/** Accessible name of the info button that shows `note`: How this order fills. Without it the note is always shown. */
|
|
25
|
+
info?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface TargetBlockProps {
|
|
28
|
+
kind: TargetKind;
|
|
29
|
+
labels: TargetBlockLabels;
|
|
30
|
+
/** Title of the price card, the position the target belongs to: `BTC · Long 40×`. */
|
|
31
|
+
position?: string;
|
|
32
|
+
/** Trailing text of the price card, the order the target places: Take-limit, Stop-market. */
|
|
33
|
+
orderType?: string;
|
|
34
|
+
/** One sentence about how the order fills. With `labels.info` it opens in a popover from an info button on the trailing edge of the header; otherwise it is always shown under the headline figure. */
|
|
35
|
+
note?: string;
|
|
36
|
+
entry: number;
|
|
37
|
+
/** Price the order triggers at. Defaults to `value` when the unit is `price`; otherwise unknown until the host supplies it. */
|
|
38
|
+
trigger?: number | null;
|
|
39
|
+
unit: TargetUnit;
|
|
40
|
+
/** Units offered, in order. Defaults to all three; one unit hides the control. */
|
|
41
|
+
units?: readonly TargetUnit[];
|
|
42
|
+
onUnitChange?: (unit: TargetUnit) => void;
|
|
43
|
+
/** 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
|
+
value: number | null;
|
|
45
|
+
onValueChange?: (value: number) => void;
|
|
46
|
+
/** Quick choices in the current unit. The one equal to `value` is shown selected. */
|
|
47
|
+
presets?: readonly number[];
|
|
48
|
+
/** Shows the Custom row; the host opens its own entry. */
|
|
49
|
+
onCustom?: () => void;
|
|
50
|
+
/** Format of prices. Defaults to US dollars. */
|
|
51
|
+
priceOptions?: Intl.NumberFormatOptions;
|
|
52
|
+
/** 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. */
|
|
53
|
+
surface?: boolean;
|
|
54
|
+
onSubmit: () => void;
|
|
55
|
+
/** Defaults to disabled while `value` is unknown. */
|
|
56
|
+
submitDisabled?: boolean;
|
|
57
|
+
busy?: boolean;
|
|
58
|
+
/** Shows Cancel beside the confirming action. */
|
|
59
|
+
onCancel?: () => void;
|
|
60
|
+
/** Shows Back on the leading edge of the header. */
|
|
61
|
+
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. */
|
|
63
|
+
headerAction?: React.ReactNode;
|
|
64
|
+
testID?: string;
|
|
65
|
+
}
|
|
66
|
+
/** 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
|
+
export declare function targetFormat(unit: TargetUnit, priceOptions?: Intl.NumberFormatOptions, short?: number): Intl.NumberFormatOptions;
|
|
68
|
+
/**
|
|
69
|
+
* Where each known price sits on the bar, as a fraction of its width from the low-price edge, the prices in price order, and
|
|
70
|
+
* the stretch (`from` to `to`) between them: the whole bar, from entry to the trigger.
|
|
71
|
+
* Without a trigger there is no stretch.
|
|
72
|
+
*/
|
|
73
|
+
export declare function targetLayout({ entry, trigger }: {
|
|
74
|
+
entry: number;
|
|
75
|
+
trigger?: number | null;
|
|
76
|
+
}): {
|
|
77
|
+
positions: Partial<Record<TargetPrice, number>>;
|
|
78
|
+
order: TargetPrice[];
|
|
79
|
+
from: number;
|
|
80
|
+
to: number;
|
|
81
|
+
};
|
|
82
|
+
/** 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;
|