@bloxwap/hig 0.6.0 → 0.8.1
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 +2 -2
- package/chart/README.md +13 -2
- package/chart/dist/altimeter-burst.d.ts +4 -0
- package/chart/dist/altimeter-burst.js +43 -0
- package/chart/dist/altimeter-chart.d.ts +52 -0
- package/chart/dist/altimeter-chart.js +275 -0
- package/chart/dist/altimeter-model.d.ts +43 -0
- package/chart/dist/altimeter-model.js +148 -0
- package/chart/dist/altimeter-targets.d.ts +33 -0
- package/chart/dist/altimeter-targets.js +88 -0
- package/chart/dist/bitcoin-price.d.ts +8 -0
- package/chart/dist/bitcoin-price.js +41 -0
- package/chart/dist/champions-league.d.ts +19 -0
- package/chart/dist/champions-league.js +104 -0
- package/chart/dist/index.d.ts +6 -0
- package/chart/dist/index.js +5 -0
- package/chart/dist/outcome-chart.d.ts +37 -0
- package/chart/dist/outcome-chart.js +212 -0
- package/chart/dist/outcome-model.d.ts +43 -0
- package/chart/dist/outcome-model.js +71 -0
- package/chart/dist/plus-grid.d.ts +6 -0
- package/chart/dist/plus-grid.js +29 -0
- package/contracts/README.md +1 -1
- package/contracts/dist/avatar.d.ts +68 -0
- package/contracts/dist/avatar.js +93 -0
- package/contracts/dist/confetti.d.ts +174 -0
- package/contracts/dist/confetti.js +138 -0
- package/contracts/dist/decimal.d.ts +7 -0
- package/contracts/dist/decimal.js +35 -0
- package/contracts/dist/index.d.ts +45 -2
- package/contracts/dist/index.js +145 -4
- package/contracts/dist/invariants.d.ts +17 -0
- package/contracts/dist/invariants.js +24 -0
- package/contracts/dist/messages.d.ts +62 -2
- package/contracts/dist/messages.js +22 -2
- package/contracts/dist/number-flow.d.ts +90 -0
- package/contracts/dist/number-flow.js +150 -0
- package/contracts/dist/qr.d.ts +151 -0
- package/contracts/dist/qr.js +581 -0
- package/contracts/dist/toast.d.ts +168 -0
- package/contracts/dist/toast.js +171 -0
- package/feedback/README.md +1 -1
- package/feedback/dist/contract.js +1 -1
- package/feedback/dist/react.js +2 -4
- package/native/README.md +6 -1
- package/native/dist/account-block.d.ts +62 -7
- package/native/dist/account-block.js +54 -11
- package/native/dist/animated-number-model.d.ts +47 -1
- package/native/dist/animated-number-model.js +248 -21
- package/native/dist/animated-number.d.ts +41 -1
- package/native/dist/animated-number.js +165 -17
- package/native/dist/announce.d.ts +2 -0
- package/native/dist/announce.js +10 -0
- package/native/dist/asset-balance-row.d.ts +19 -1
- package/native/dist/asset-balance-row.js +24 -8
- package/native/dist/assets-block.d.ts +115 -0
- package/native/dist/assets-block.js +87 -0
- package/native/dist/async-result.d.ts +2 -0
- package/native/dist/async-result.js +11 -0
- package/native/dist/avatar-frame.d.ts +29 -0
- package/native/dist/avatar-frame.js +56 -0
- package/native/dist/avatar.d.ts +21 -0
- package/native/dist/avatar.js +31 -0
- package/native/dist/bar-mark.d.ts +16 -2
- package/native/dist/bar-mark.js +23 -7
- package/native/dist/bar-pnl.js +7 -5
- package/native/dist/blocks.d.ts +13 -14
- package/native/dist/blocks.js +10 -6
- package/native/dist/brand.js +2 -1
- package/native/dist/button.d.ts +7 -2
- package/native/dist/button.js +16 -4
- package/native/dist/checkbox.js +2 -1
- package/native/dist/confetti.d.ts +33 -0
- package/native/dist/confetti.js +143 -0
- package/native/dist/confirm-block.d.ts +98 -0
- package/native/dist/confirm-block.js +48 -0
- package/native/dist/data.d.ts +1 -1
- package/native/dist/data.js +8 -4
- package/native/dist/explainer-block.d.ts +91 -0
- package/native/dist/explainer-block.js +34 -0
- package/native/dist/field.d.ts +19 -5
- package/native/dist/field.js +56 -9
- package/native/dist/figure.d.ts +23 -0
- package/native/dist/figure.js +10 -0
- package/native/dist/gesture-sheet-model.d.ts +50 -0
- package/native/dist/gesture-sheet-model.js +105 -0
- package/native/dist/gesture-sheet-next.d.ts +82 -0
- package/native/dist/gesture-sheet-next.js +315 -0
- package/native/dist/gesture-sheet.d.ts +5 -1
- package/native/dist/gesture-sheet.js +13 -6
- package/native/dist/icons.d.ts +9 -6
- package/native/dist/icons.js +25 -24
- package/native/dist/language-block.d.ts +14 -1
- package/native/dist/language-block.js +11 -4
- package/native/dist/list-group.d.ts +44 -8
- package/native/dist/list-group.js +84 -13
- package/native/dist/manage-position-block.d.ts +35 -2
- package/native/dist/manage-position-block.js +41 -11
- package/native/dist/market-row.d.ts +46 -0
- package/native/dist/market-row.js +41 -0
- package/native/dist/navigation.js +5 -3
- package/native/dist/notifications-block.d.ts +30 -2
- package/native/dist/notifications-block.js +16 -8
- package/native/dist/number-format.d.ts +6 -0
- package/native/dist/number-format.js +9 -0
- package/native/dist/pickers.d.ts +32 -2
- package/native/dist/pickers.js +17 -9
- package/native/dist/position-block.d.ts +66 -10
- package/native/dist/position-block.js +45 -11
- package/native/dist/preset-group.d.ts +31 -0
- package/native/dist/preset-group.js +39 -0
- package/native/dist/preset-picker-block.d.ts +107 -0
- package/native/dist/preset-picker-block.js +43 -0
- package/native/dist/profile-block.d.ts +38 -5
- package/native/dist/profile-block.js +31 -6
- package/native/dist/provider.d.ts +14 -5
- package/native/dist/provider.js +32 -6
- package/native/dist/qr-code.d.ts +33 -0
- package/native/dist/qr-code.js +29 -0
- package/native/dist/radio-group.d.ts +23 -5
- package/native/dist/radio-group.js +40 -12
- package/native/dist/recipes.d.ts +6 -0
- package/native/dist/recipes.js +6 -0
- package/native/dist/reward-block.d.ts +55 -13
- package/native/dist/reward-block.js +37 -14
- package/native/dist/screen-header.d.ts +59 -0
- package/native/dist/screen-header.js +37 -0
- package/native/dist/select.js +4 -2
- package/native/dist/selection.d.ts +3 -2
- package/native/dist/selection.js +1 -0
- package/native/dist/setting-header.d.ts +2 -8
- package/native/dist/setting-header.js +2 -11
- package/native/dist/setting-switch.d.ts +15 -2
- package/native/dist/setting-switch.js +11 -4
- package/native/dist/signals-block.d.ts +26 -2
- package/native/dist/signals-block.js +14 -4
- package/native/dist/slider.js +5 -1
- package/native/dist/sound-haptics-block.d.ts +29 -2
- package/native/dist/sound-haptics-block.js +19 -8
- package/native/dist/status.d.ts +47 -14
- package/native/dist/status.js +39 -22
- package/native/dist/sticky-header.d.ts +28 -0
- package/native/dist/sticky-header.js +29 -0
- package/native/dist/surface.d.ts +3 -1
- package/native/dist/surface.js +2 -1
- package/native/dist/swap-amount-card.d.ts +57 -0
- package/native/dist/swap-amount-card.js +31 -0
- package/native/dist/swap-panel-block.d.ts +11 -4
- package/native/dist/swap-panel-block.js +67 -38
- package/native/dist/swap-parts.d.ts +5 -10
- package/native/dist/swap-parts.js +22 -24
- package/native/dist/swap-shared.d.ts +8 -2
- package/native/dist/swap-shared.js +10 -6
- package/native/dist/swap-views.js +6 -4
- 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 +40 -7
- package/native/dist/target-block.js +31 -11
- package/native/dist/toast.d.ts +47 -0
- package/native/dist/toast.js +386 -0
- package/native/dist/token-action-block.d.ts +26 -9
- package/native/dist/token-action-block.js +21 -8
- 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 +55 -17
- package/native/dist/wallet-address-core.d.ts +25 -0
- package/native/dist/wallet-address-core.js +34 -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 +131 -2
- package/react/README.md +3 -1
- package/react/dist/animated-number-flow.d.ts +72 -0
- package/react/dist/animated-number-flow.js +316 -0
- package/react/dist/animated-number-model.d.ts +24 -0
- package/react/dist/animated-number-model.js +106 -3
- package/react/dist/animated-number.d.ts +49 -1
- package/react/dist/animated-number.js +146 -11
- package/react/dist/asset-balance-row.d.ts +19 -1
- package/react/dist/asset-balance-row.js +17 -3
- package/react/dist/async-result.d.ts +2 -0
- package/react/dist/async-result.js +11 -0
- package/react/dist/avatar.d.ts +25 -0
- package/react/dist/avatar.js +50 -0
- 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 +57 -7
- package/react/dist/blocks/account-block.js +51 -11
- package/react/dist/blocks/assets-block.d.ts +106 -0
- package/react/dist/blocks/assets-block.js +135 -0
- package/react/dist/blocks/confirm-block.d.ts +91 -0
- package/react/dist/blocks/confirm-block.js +31 -0
- package/react/dist/blocks/explainer-block.d.ts +80 -0
- package/react/dist/blocks/explainer-block.js +20 -0
- package/react/dist/blocks/install-command.js +3 -1
- package/react/dist/blocks/language-block.d.ts +9 -1
- package/react/dist/blocks/language-block.js +8 -6
- package/react/dist/blocks/manage-position-block.d.ts +30 -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 +17 -4
- package/react/dist/blocks/notifications-block.d.ts +27 -2
- package/react/dist/blocks/notifications-block.js +11 -2
- package/react/dist/blocks/pickers.d.ts +30 -1
- package/react/dist/blocks/pickers.js +32 -10
- package/react/dist/blocks/position-block.d.ts +34 -11
- package/react/dist/blocks/position-block.js +16 -5
- package/react/dist/blocks/preset-picker-block.d.ts +85 -0
- package/react/dist/blocks/preset-picker-block.js +19 -0
- package/react/dist/blocks/profile-block.d.ts +33 -6
- package/react/dist/blocks/profile-block.js +31 -6
- package/react/dist/blocks/reward-block.d.ts +65 -21
- package/react/dist/blocks/reward-block.js +24 -11
- package/react/dist/blocks/screen-header.d.ts +34 -2
- package/react/dist/blocks/screen-header.js +17 -6
- package/react/dist/blocks/setting-switch.d.ts +14 -1
- package/react/dist/blocks/setting-switch.js +11 -4
- package/react/dist/blocks/signals-block.d.ts +23 -2
- package/react/dist/blocks/signals-block.js +6 -5
- package/react/dist/blocks/sound-haptics-block.d.ts +27 -3
- package/react/dist/blocks/sound-haptics-block.js +11 -7
- package/react/dist/blocks/sticky-header.d.ts +19 -0
- package/react/dist/blocks/sticky-header.js +103 -0
- package/react/dist/blocks/swap/amount-card.js +2 -1
- package/react/dist/blocks/swap/settings.js +4 -3
- package/react/dist/blocks/swap/shared.d.ts +29 -23
- package/react/dist/blocks/swap/shared.js +36 -32
- package/react/dist/blocks/swap-panel-block.d.ts +12 -3
- package/react/dist/blocks/swap-panel-block.js +72 -37
- package/react/dist/blocks/target-block.d.ts +35 -7
- package/react/dist/blocks/target-block.js +26 -12
- package/react/dist/blocks/token-action-block.d.ts +21 -8
- package/react/dist/blocks/token-action-block.js +9 -6
- package/react/dist/blocks/trade-history-detail-block.d.ts +23 -1
- package/react/dist/blocks/trade-history-detail-block.js +5 -4
- package/react/dist/blocks/trade-history-list-block.d.ts +31 -5
- package/react/dist/blocks/trade-history-list-block.js +20 -10
- package/react/dist/blocks.d.ts +12 -8
- package/react/dist/blocks.js +6 -2
- package/react/dist/brand.js +2 -1
- package/react/dist/button.d.ts +9 -3
- package/react/dist/button.js +12 -5
- package/react/dist/confetti.d.ts +27 -0
- package/react/dist/confetti.js +240 -0
- package/react/dist/data.js +11 -4
- package/react/dist/field.d.ts +20 -5
- package/react/dist/field.js +30 -8
- package/react/dist/figure.d.ts +23 -0
- package/react/dist/figure.js +12 -0
- package/react/dist/gesture-sheet.d.ts +15 -1
- package/react/dist/gesture-sheet.js +53 -8
- package/react/dist/list-group.d.ts +41 -8
- package/react/dist/list-group.js +49 -13
- package/react/dist/navigation.js +11 -3
- package/react/dist/overlay.d.ts +28 -3
- package/react/dist/overlay.js +29 -3
- package/react/dist/preset-group.d.ts +30 -0
- package/react/dist/preset-group.js +13 -0
- package/react/dist/provider.d.ts +42 -5
- package/react/dist/provider.js +84 -10
- package/react/dist/qr-code.d.ts +32 -0
- package/react/dist/qr-code.js +28 -0
- package/react/dist/select.js +10 -3
- package/react/dist/selection.d.ts +18 -4
- package/react/dist/selection.js +20 -10
- package/react/dist/slider.js +5 -1
- package/react/dist/status.d.ts +14 -10
- package/react/dist/status.js +17 -9
- package/react/dist/styles.css +380 -150
- package/react/dist/surface.d.ts +5 -1
- package/react/dist/surface.js +1 -1
- package/react/dist/toast.d.ts +19 -12
- package/react/dist/toast.js +29 -7
- package/react/dist/wallet-address-core.d.ts +27 -0
- package/react/dist/wallet-address-core.js +29 -0
- package/react/dist/wallet-address.d.ts +6 -12
- package/react/dist/wallet-address.js +5 -16
- package/tokens/README.md +2 -2
- package/tokens/dist/index.d.ts +16 -0
- package/tokens/dist/index.js +16 -0
- package/tokens/dist/manifest.json +8 -0
- package/tokens/dist/tokens.css +6 -0
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Image, Pressable, View } from 'react-native';
|
|
4
|
+
import { StickyHeaderLayout } from './sticky-header.js';
|
|
5
|
+
import { useColors, useFills, useHIG, useMessages, useNumberLocale, usePresentNumber } from './provider.js';
|
|
4
6
|
import { Text } from './surface.js';
|
|
5
7
|
import { IconButton } from './button.js';
|
|
6
8
|
import { ChevronIcon } from './icons.js';
|
|
7
9
|
import { AnimatedNumberReadout } from './animated-number.js';
|
|
10
|
+
import { figureProps, figureReading } from './figure.js';
|
|
8
11
|
import { formatNumberReadout } from './animated-number-model.js';
|
|
9
12
|
import { BarMark } from './bar-mark.js';
|
|
10
13
|
import { BarPnl } from './bar-pnl.js';
|
|
11
14
|
import { ListGroup, ListRow } from './list-group.js';
|
|
12
15
|
const usd = { style: 'currency', currency: 'USD' };
|
|
13
|
-
const
|
|
16
|
+
const pnlUsdDefault = { style: 'currency', currency: 'USD', signDisplay: 'exceptZero', maximumFractionDigits: 4 };
|
|
14
17
|
const pnlShare = { style: 'percent', minimumFractionDigits: 2, maximumFractionDigits: 2, signDisplay: 'exceptZero' };
|
|
15
18
|
const units = { maximumFractionDigits: 6 };
|
|
16
19
|
const tenth = { maximumFractionDigits: 1 };
|
|
@@ -36,9 +39,12 @@ function Sentence({ template, text, value, options, suffix, testID }) {
|
|
|
36
39
|
return _jsxs(View, { accessible: true, accessibilityLabel: reading, testID: testID, style: { direction, flexDirection: 'row', alignItems: 'center', flexShrink: 1 }, children: [parts[0] ? _jsx(Text, { accessible: false, style: words, children: parts[0] }) : null, _jsx(AnimatedNumberReadout, { value: value, options: options, suffix: suffix, tone: 'muted', style: type }), parts[1] ? _jsx(Text, { accessible: false, style: words, children: parts[1] }) : null] });
|
|
37
40
|
}
|
|
38
41
|
/** One open position as a screen: margin and notional under the share left before liquidation, then the liquidation, mark and entry prices as a `BarPnl`, what can be done, and the position itself. Both bars are drawn without a card, because nothing in them can be pressed. */
|
|
39
|
-
export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, onBack, headerAction, testID }) {
|
|
40
|
-
const colors = useColors(), fills = useFills(), t = useMessages(), { direction, locale
|
|
41
|
-
|
|
42
|
+
export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, stickyHeader, stickyHeaderBackground, scrollComponent, testID }) {
|
|
43
|
+
const colors = useColors(), fills = useFills(), t = useMessages(), { direction } = useHIG(), locale = useNumberLocale(), present = usePresentNumber();
|
|
44
|
+
// The artwork that failed to draw (its URL, or the position for a host element); it then shows the fallback or the initials until the artwork changes.
|
|
45
|
+
const [broken, setBroken] = useState(null);
|
|
46
|
+
const pnlUsd = pnlOptions ? { ...pnlUsdDefault, ...pnlOptions } : pnlUsdDefault;
|
|
47
|
+
const read = (value, options) => known(value) ? formatNumberReadout(value, locale, present(options)).text : unknown;
|
|
42
48
|
const corridor = positionCorridor({ side, entry, mark, liquidation }), long = side === 'long';
|
|
43
49
|
const marginBar = [{ id: 'margin', label: labels.margin, value: margin, detail: read(margin, usd), tone: 'info' }, { id: 'notional', label: labels.notional, value: known(notional) ? Math.max(notional - margin, 0) : 0, detail: read(notional, usd), tone: 'positive' }];
|
|
44
50
|
const left = corridor.share === null ? null : corridor.share * 100;
|
|
@@ -46,12 +52,36 @@ export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidati
|
|
|
46
52
|
const row = () => {
|
|
47
53
|
if (!position)
|
|
48
54
|
return null;
|
|
49
|
-
const { name, icon, leverage, size, pnl, pnlPercent } = position;
|
|
50
|
-
const
|
|
55
|
+
const { name, icon, iconFallback, symbol, leverage, size, pnl, pnlPercent, badge, caption, onSelect } = position;
|
|
56
|
+
const initials = _jsx(Text, { accessible: false, maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: symbol ?? name.slice(0, 3) });
|
|
57
|
+
const key = typeof icon === 'string' ? icon : `${symbol ?? ''}|${name}`, failed = broken === key, fail = () => setBroken(key);
|
|
58
|
+
const art = failed ? _jsx(View, { testID: 'manage-position-initials', style: shape, children: iconFallback ?? initials })
|
|
59
|
+
: typeof icon === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: icon }, onError: fail, style: shape })
|
|
60
|
+
: _jsx(View, { style: shape, children: typeof icon === 'function' ? icon(fail) : icon ?? initials });
|
|
51
61
|
const gearing = known(leverage) ? formatNumberReadout(leverage, locale, units).text + times : null, held = size !== undefined ? read(size, units) : null;
|
|
52
62
|
const label = [name, long ? labels.long : labels.short, gearing, held, pnl !== undefined ? read(pnl, pnlUsd) : null, pnlPercent !== undefined ? read(pnlPercent, pnlShare) : null].filter(Boolean).join(', ');
|
|
53
63
|
const meta = { fontSize: 14, lineHeight: 20 };
|
|
54
|
-
|
|
64
|
+
const title = _jsx(Text, { numberOfLines: 1, style: { fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.text, ...(badge ? { flexShrink: 1 } : null) }, children: name });
|
|
65
|
+
const surface = (pressed) => ({ flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 56, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 28, backgroundColor: pressed ? fills.raised : fills.well, marginTop: 16 });
|
|
66
|
+
const parts = _jsxs(_Fragment, { children: [_jsx(View, { ...hidden, children: art }), _jsxs(View, { ...hidden, style: { flex: 1, flexShrink: 1, minWidth: 0 }, children: [badge ? _jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', gap: 8, minWidth: 0 }, children: [title, _jsx(View, { testID: 'manage-position-badge', style: { flexShrink: 0, borderRadius: 9999, paddingHorizontal: 8, backgroundColor: fills.raised }, children: _jsx(Text, { numberOfLines: 1, style: { fontSize: 12, lineHeight: 18, fontWeight: '500', color: colors.muted }, children: badge }) })] }) : title, _jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', gap: 4 }, children: [_jsx(Text, { testID: 'manage-position-side', style: { ...meta, fontWeight: '600', color: long ? colors.up : colors.down }, children: long ? up : down }), gearing ? _jsx(Text, { testID: 'manage-position-leverage', style: { ...meta, fontWeight: '600', color: long ? colors.up : colors.down }, children: gearing }) : null, gearing && held ? _jsx(Text, { style: { ...meta, color: colors.muted }, children: dot.trim() }) : null, size !== undefined ? _jsx(AnimatedNumberReadout, { value: size, options: units, tone: 'muted', testID: 'manage-position-size', style: meta }) : null] })] }), _jsxs(View, { ...hidden, style: { alignItems: 'flex-end', justifyContent: 'center' }, children: [pnl !== undefined ? _jsx(AnimatedNumberReadout, { value: pnl, options: pnlUsd, tone: known(pnl) && pnl > 0 ? 'up' : known(pnl) && pnl < 0 ? 'down' : 'text', testID: 'manage-position-pnl', style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) : null, pnlPercent !== undefined ? _jsx(AnimatedNumberReadout, { value: pnlPercent, options: pnlShare, tone: 'muted', testID: 'manage-position-pnl-percent', style: meta }) : null] })] });
|
|
67
|
+
const note = caption ? _jsx(Text, { testID: 'manage-position-caption', style: { marginTop: 8, paddingHorizontal: 16, color: colors.muted, fontSize: 13, lineHeight: 20 }, children: caption }) : null;
|
|
68
|
+
if (onSelect) {
|
|
69
|
+
// A pressable row is named by the host's label and then what it shows, so the figures are read even with hints off; the caption is its hint.
|
|
70
|
+
return _jsxs(_Fragment, { children: [_jsx(Pressable, { testID: 'manage-position-row', accessibilityRole: 'button', accessibilityLabel: position.label ? `${position.label}, ${label}` : label, accessibilityHint: caption, onPress: onSelect, style: ({ pressed }) => surface(pressed), children: parts }), note] });
|
|
71
|
+
}
|
|
72
|
+
return _jsxs(_Fragment, { children: [_jsx(View, { testID: 'manage-position-row', accessible: true, accessibilityLabel: label, style: surface(false), children: parts }), note] });
|
|
55
73
|
};
|
|
56
|
-
|
|
74
|
+
const actionValue = (action) => {
|
|
75
|
+
const figure = action.value;
|
|
76
|
+
if (figure == null)
|
|
77
|
+
return {};
|
|
78
|
+
if (typeof figure === 'string')
|
|
79
|
+
return { value: figure, valueTone: action.tone };
|
|
80
|
+
return { value: _jsx(AnimatedNumberReadout, { ...figureProps(figure), tone: action.tone ?? 'muted', testID: `manage-action-${action.id}-value`, style: { fontSize: 16, lineHeight: 24 } }), valueLabel: figureReading(figure, locale, present(figure.options)) };
|
|
81
|
+
};
|
|
82
|
+
const header = _jsxs(View, { testID: 'manage-header', style: { flexDirection: 'row', alignItems: 'center', minHeight: 44 }, children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onBack ? _jsx(IconButton, { intent: 'ghost', label: t.back, suppressFeedback: true, testID: 'manage-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'manage-title', 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: 44, alignItems: 'flex-end' }, children: headerAction })] });
|
|
83
|
+
const body = _jsxs(_Fragment, { children: [_jsxs(View, { style: { gap: 20, marginTop: 16, paddingHorizontal: 4 }, children: [_jsx(BarMark, { testID: 'manage-margin', surface: false, title: mode ?? labels.margin, elements: marginBar, description: _jsx(Sentence, { testID: 'manage-to-liquidation', template: labels.toLiquidation, text: left === null ? unknown : formatNumberReadout(left, locale, tenth).text + percent, value: left, options: tenth, suffix: percent }) }), _jsx(BarPnl, { testID: 'manage-liquidation', surface: false, compact: true, side: side, entry: entry, mark: mark, liquidation: liquidation, labels: { liquidation: labels.liquidation, mark: labels.mark, entry: labels.entry }, priceOptions: priceOptions })] }), actions.length > 0 ? _jsx(View, { testID: 'manage-actions', style: { marginTop: 16 }, children: _jsx(ListGroup, { children: actions.map(action => _jsx(ListRow, { testID: `manage-action-${action.id}`, label: action.label, disabled: action.disabled, onSelect: action.onSelect, ...actionValue(action) }, action.id)) }) }) : null, row()] });
|
|
84
|
+
if (stickyHeader)
|
|
85
|
+
return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: 'manage-sticky-header', header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: body });
|
|
86
|
+
return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [header, body] });
|
|
57
87
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, type GestureResponderEvent, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
interface MarketRowContent {
|
|
4
|
+
symbol: string;
|
|
5
|
+
name: string;
|
|
6
|
+
/** Leave out to draw no price (no dash); `null` reads as unknown. */
|
|
7
|
+
price?: number | null;
|
|
8
|
+
/** Leave out to draw no change (no dash); `null` reads as unknown. */
|
|
9
|
+
change?: number | null;
|
|
10
|
+
/** Intl display options for the price, including a decimal style when the host omits a currency symbol. */
|
|
11
|
+
priceOptions?: Intl.NumberFormatOptions;
|
|
12
|
+
/** Percent-point display precision and sign, forwarded to `Percent`. */
|
|
13
|
+
changeOptions?: Intl.NumberFormatOptions;
|
|
14
|
+
/** Host artwork before the name, such as the market icon. Decorative. */
|
|
15
|
+
icon?: React.ReactNode;
|
|
16
|
+
/** Host favourite indicator or control before the icon. */
|
|
17
|
+
favorite?: React.ReactNode;
|
|
18
|
+
/** Host-formatted volume after the change. */
|
|
19
|
+
volume?: React.ReactNode;
|
|
20
|
+
/** A muted second line under the name, such as the maximum leverage. Text, or host nodes (text nodes are drawn muted; an element is drawn as given). In action mode its text is read with the name. */
|
|
21
|
+
detail?: React.ReactNode;
|
|
22
|
+
/** Host content on the trailing edge, after the figures, such as a held position's result. */
|
|
23
|
+
trailing?: React.ReactNode;
|
|
24
|
+
/** The market in use: a check on the trailing edge and `accessibilityState.selected` on the name button (the row in presentation mode). */
|
|
25
|
+
selected?: boolean;
|
|
26
|
+
/** Dims the row; in action mode the name button is disabled. */
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/** Highlights the row with the well fill, as for a host's keyboard cursor. */
|
|
29
|
+
active?: boolean;
|
|
30
|
+
/** Action mode: called when a press starts on the name button, before it is accepted, for example to prefetch the market. */
|
|
31
|
+
onPressIn?: (event: GestureResponderEvent) => void;
|
|
32
|
+
testID?: string;
|
|
33
|
+
style?: StyleProp<ViewStyle>;
|
|
34
|
+
}
|
|
35
|
+
export type MarketRowProps = MarketRowContent & ({
|
|
36
|
+
mode?: 'action';
|
|
37
|
+
onSelect: () => void;
|
|
38
|
+
identity?: never;
|
|
39
|
+
} | {
|
|
40
|
+
mode: 'presentation';
|
|
41
|
+
onSelect?: never; /** Host market identity in place of `name (symbol)`. */
|
|
42
|
+
identity?: React.ReactNode;
|
|
43
|
+
});
|
|
44
|
+
/** A market as one row: its name (a button, or the host's identity in presentation mode), price and change. The ref reaches the row's root view. */
|
|
45
|
+
export declare const MarketRow: React.ForwardRefExoticComponent<MarketRowProps & React.RefAttributes<React.ComponentRef<typeof View>>>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check } from '@bloxwap/icons/native/check';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { useColors, useFills } from './provider.js';
|
|
6
|
+
import { Button } from './button.js';
|
|
7
|
+
import { Text } from './surface.js';
|
|
8
|
+
import { Row, Usd, Percent } from './data.js';
|
|
9
|
+
import { plainText } from './text-content.js';
|
|
10
|
+
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
11
|
+
/** A market as one row: its name (a button, or the host's identity in presentation mode), price and change. The ref reaches the row's root view. */
|
|
12
|
+
export const MarketRow = /* @__PURE__ */ forwardRef(function MarketRow({ symbol, name, price, change, priceOptions, changeOptions, mode = 'action', onSelect, identity, icon, favorite, volume, detail, trailing, selected, disabled, active, onPressIn, testID, style }, ref) {
|
|
13
|
+
const colors = useColors(), fills = useFills();
|
|
14
|
+
const label = `${name} (${symbol})`;
|
|
15
|
+
// A row with host options is one line: the name and its detail truncate rather than wrap, so the trailing cells keep their place.
|
|
16
|
+
const lines = detail === undefined ? null : _jsxs(View, { style: { alignItems: 'flex-start', flexShrink: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { fontSize: 16, lineHeight: 24, fontWeight: '600', color: disabled ? colors.muted : colors.text }, children: label }), typeof detail === 'string' || typeof detail === 'number' ? _jsx(Text, { numberOfLines: 1, style: { fontSize: 14, lineHeight: 20, color: colors.muted }, children: detail }) : detail] });
|
|
17
|
+
const detailText = detail === undefined ? '' : plainText(detail);
|
|
18
|
+
// When the row is too narrow for everything, space is given up in this order (as on web): the name truncates down to a floor (the
|
|
19
|
+
// name cell's basis is 96dp and it never shrinks, so the icon never leaves the identity and the start of the name stays readable);
|
|
20
|
+
// then whole figures drop from the end (volume, change, price); then the trailing content is clipped. The check keeps its place.
|
|
21
|
+
const nameCell = { flexGrow: 1, flexShrink: 0, flexBasis: 96, minWidth: 0 };
|
|
22
|
+
const title = mode === 'presentation'
|
|
23
|
+
? _jsx(View, { style: disabled ? { opacity: 0.5, ...nameCell } : nameCell, children: identity ?? lines ?? _jsx(Text, { numberOfLines: 1, children: label }) })
|
|
24
|
+
: lines ? _jsx(Button, { intent: 'ghost', contentMode: 'custom', accessibilityLabel: detailText ? `${label}, ${detailText}` : label, accessibilityState: selected ? { selected: true } : undefined, disabled: disabled, onPress: onSelect, onPressIn: onPressIn, testID: testID ? `${testID}-select` : undefined, style: { alignItems: 'flex-start', ...nameCell, paddingVertical: 0 }, children: lines })
|
|
25
|
+
: _jsx(Button, { intent: 'ghost', contentMode: 'custom', accessibilityLabel: label, accessibilityState: selected ? { selected: true } : undefined, disabled: disabled, onPress: onSelect, onPressIn: onPressIn, testID: testID ? `${testID}-select` : undefined, style: { alignItems: 'flex-start', ...nameCell }, children: _jsx(Text, { numberOfLines: 1, style: { fontSize: 16, fontWeight: '600', color: disabled ? colors.faint : colors.muted }, children: label }) });
|
|
26
|
+
const leading = favorite !== undefined || icon !== undefined;
|
|
27
|
+
// The identity's basis is its favourite + icon + the name cell's 96dp, and it does not shrink: that is the floor.
|
|
28
|
+
const identityCell = _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: leading ? 8 : 0, flexGrow: 1, flexShrink: 0, flexBasis: 'auto' }, children: [favorite !== undefined ? _jsx(View, { style: { flexShrink: 0 }, children: favorite }) : null, icon !== undefined ? _jsx(View, { ...hidden, style: { flexShrink: 0 }, children: icon }) : null, title] });
|
|
29
|
+
const dim = disabled ? { opacity: 0.5 } : null;
|
|
30
|
+
// The figures are one 44dp line that wraps and clips, so a figure that does not fit moves to the hidden second line instead of being
|
|
31
|
+
// cut; the zero-width first item lets even the price wrap away. Their large shrink factor makes them give up space before the trailing content.
|
|
32
|
+
const figure = (node) => _jsx(View, { style: [{ height: 44, justifyContent: 'center', marginStart: 12, flexShrink: 0 }, dim], children: node });
|
|
33
|
+
const figures = price === undefined && change === undefined && volume === undefined ? null : _jsxs(View, { testID: testID ? `${testID}-figures` : undefined, style: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'flex-end', alignContent: 'flex-start', height: 44, overflow: 'hidden', flexGrow: 0, flexShrink: 1000, minWidth: 0, marginStart: -12 }, children: [_jsx(View, { style: { width: 0, height: 44 } }), price !== undefined ? figure(_jsx(Usd, { value: price, options: priceOptions })) : null, change !== undefined ? figure(_jsx(Percent, { value: change, options: changeOptions })) : null, volume !== undefined ? figure(volume) : null] });
|
|
34
|
+
const cells = _jsxs(_Fragment, { children: [identityCell, figures, trailing != null && trailing !== false ? _jsx(View, { testID: testID ? `${testID}-trailing` : undefined, style: [{ flexDirection: 'row', alignItems: 'center', gap: 8, flexShrink: 1, minWidth: 0, overflow: 'hidden' }, dim], children: trailing }) : null, selected ? _jsx(Check, { size: 20, color: colors.text, testID: testID ? `${testID}-check` : undefined }) : null] });
|
|
35
|
+
const plain = !ref && !leading && detail === undefined && price !== undefined && change !== undefined && volume === undefined && trailing == null && !selected && !disabled && !active && !onPressIn && mode === 'action' && !testID && !style;
|
|
36
|
+
// Without host options the row is exactly the 0.6.0 one: the name button, the price and the change in a wrapping Row.
|
|
37
|
+
if (plain)
|
|
38
|
+
return _jsxs(Row, { children: [_jsxs(Button, { intent: 'ghost', onPress: onSelect, children: [name, " (", symbol, ")"] }), _jsx(Usd, { value: price, options: priceOptions }), _jsx(Percent, { value: change, options: changeOptions })] });
|
|
39
|
+
const state = mode === 'presentation' && (selected || disabled) ? { ...(selected ? { selected: true } : {}), ...(disabled ? { disabled: true } : {}) } : undefined;
|
|
40
|
+
return _jsx(View, { ref: ref, testID: testID, accessibilityState: state, style: [{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', flexWrap: 'nowrap', gap: 12, paddingVertical: 8 }, active ? { backgroundColor: fills.well, borderRadius: 14 } : null, style], children: cells });
|
|
41
|
+
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { assertUniqueKeys, paginationValue } from '@bloxwap/hig/contracts';
|
|
2
3
|
import { useEffect, useRef, useState } from 'react';
|
|
3
4
|
import { Animated, Easing, Pressable, View } from 'react-native';
|
|
4
5
|
import { tokens } from '@bloxwap/hig/tokens';
|
|
5
6
|
import { ChevronIcon } from './icons.js';
|
|
6
|
-
import { formatNumber } from '
|
|
7
|
+
import { formatNumber } from './number-format.js';
|
|
7
8
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
8
9
|
import { useColors, useControllable, useFills, useHIG } from './provider.js';
|
|
9
10
|
import { Button } from './button.js';
|
|
@@ -11,7 +12,8 @@ import { Text, Inline, Stack, Surface } from './surface.js';
|
|
|
11
12
|
import { Field, SearchInput } from './field.js';
|
|
12
13
|
/** Actions that sit side by side are 8dp apart; content keeps the 12dp gap. */
|
|
13
14
|
const actionRow = { gap: tokens.space.sm };
|
|
14
|
-
export function Tabs({ label, items, value, defaultValue, onValueChange }) { const colors = useColors(); const fills = useFills(); const { direction } = useHIG(); const [
|
|
15
|
+
export function Tabs({ label, items, value, defaultValue, onValueChange }) { const colors = useColors(); const fills = useFills(); const { direction } = useHIG(); const [stored, set] = useControllable(value, defaultValue ?? items.find(item => !item.disabled)?.value ?? '', onValueChange); assertUniqueKeys(items, item => item.value, 'Tabs'); const controlled = useRef(value !== undefined).current; const current = items.some(item => item.value === stored && !item.disabled) ? stored : controlled ? '' : items.find(item => !item.disabled)?.value ?? ''; useEffect(() => { if (!controlled && stored !== current)
|
|
16
|
+
set(current); }, [controlled, stored, current]); return _jsxs(View, { style: { direction, gap: 12 }, children: [_jsx(Inline, { style: actionRow, accessibilityRole: 'tablist', accessibilityLabel: label, children: items.map(i => _jsx(Pressable, { accessibilityRole: 'tab', "aria-selected": current === i.value, "aria-disabled": !!i.disabled, accessibilityState: { selected: current === i.value, disabled: !!i.disabled }, disabled: i.disabled, onPress: () => { if (!i.disabled)
|
|
15
17
|
set(i.value); }, hitSlop: { top: 2, bottom: 2 }, style: ({ pressed }) => ({ minHeight: 44, paddingHorizontal: 20, paddingVertical: 10, borderRadius: 9999, alignItems: 'center', justifyContent: 'center', backgroundColor: current === i.value ? fills.raised : 'transparent', opacity: i.disabled ? .5 : pressed ? .85 : 1 }), children: _jsx(Text, { style: { fontWeight: '600', color: current === i.value ? colors.text : colors.muted }, children: i.label }) }, i.value)) }), items.find(i => i.value === current)?.content] }); }
|
|
16
18
|
/** A strokeless card. The outline chevron sits on the trailing edge and turns as the content expands or collapses; with reduced motion both change at once. */
|
|
17
19
|
export function Accordion({ title, children, open, onOpenChange }) {
|
|
@@ -53,6 +55,6 @@ export function Accordion({ title, children, open, onOpenChange }) {
|
|
|
53
55
|
}
|
|
54
56
|
export function Navigation({ label, items }) { const colors = useColors(); return _jsx(Stack, { accessibilityLabel: label, style: { gap: 4 }, children: items.map(i => _jsx(Button, { fullWidth: true, intent: 'ghost', accessibilityState: { selected: !!i.active }, onPress: i.onNavigate, style: { alignItems: 'flex-start', backgroundColor: i.active ? colors.nested : 'transparent' }, children: i.label }, i.id)) }); }
|
|
55
57
|
export const BottomNavigation = Navigation;
|
|
56
|
-
export function Pagination({ page, total, onPageChange }) { const { locale, messages } = useHIG(); return _jsxs(Inline, { style: actionRow, children: [_jsx(Button, { intent: 'secondary', disabled: page <= 1, onPress: () => onPageChange(page - 1), children: messages.previous ?? en.previous }), _jsx(Text, { children: (messages.pageOf ?? en.pageOf)(formatNumber(page, locale), formatNumber(total, locale)) }), _jsx(Button, { intent: 'secondary', disabled: page >= total, onPress: () => onPageChange(page + 1), children: messages.next ?? en.next })] }); }
|
|
58
|
+
export function Pagination({ page, total, onPageChange }) { ({ page, total } = paginationValue(page, total)); const { locale, messages } = useHIG(); return _jsxs(Inline, { style: actionRow, children: [_jsx(Button, { intent: 'secondary', disabled: page <= 1, onPress: () => onPageChange(page - 1), children: messages.previous ?? en.previous }), _jsx(Text, { children: (messages.pageOf ?? en.pageOf)(formatNumber(page, locale), formatNumber(total, locale)) }), _jsx(Button, { intent: 'secondary', disabled: page >= total, onPress: () => onPageChange(page + 1), children: messages.next ?? en.next })] }); }
|
|
57
59
|
export function Search({ query, onQueryChange, results, loading, error }) { const { locale, messages } = useHIG(); return _jsxs(Stack, { children: [_jsx(Field, { label: messages.search ?? en.search, children: _jsx(SearchInput, { value: query, onChangeText: onQueryChange }) }), _jsx(Text, { accessibilityLiveRegion: 'polite', children: loading ? messages.searching ?? en.searching : error ?? (results.length ? (messages.resultCount ?? en.resultCount)(results.length, locale) : messages.noResults ?? en.noResults) }), !loading && !error && results.map(r => _jsx(Button, { intent: 'ghost', onPress: r.onSelect, children: r.label }, r.id))] }); }
|
|
58
60
|
export function BackButton({ onBack }) { const { messages } = useHIG(); return _jsx(Button, { intent: 'secondary', onPress: onBack, children: messages.back ?? en.back }); }
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type ScrollViewProps } from 'react-native';
|
|
3
|
+
import { type SettingAction } from './setting-switch.js';
|
|
2
4
|
/** One kind of notification. Every word is host text. */
|
|
3
5
|
export interface NotificationsItem {
|
|
4
6
|
id: string;
|
|
@@ -7,19 +9,45 @@ export interface NotificationsItem {
|
|
|
7
9
|
checked: boolean;
|
|
8
10
|
onCheckedChange: (checked: boolean) => void;
|
|
9
11
|
disabled?: boolean;
|
|
12
|
+
/** Always on and not changeable: shown on at full strength and read as unavailable. */
|
|
13
|
+
locked?: boolean;
|
|
14
|
+
/** Host content after the label, such as a badge. It is drawn only; the switch is read by `label`. */
|
|
15
|
+
labelAccessory?: React.ReactNode;
|
|
16
|
+
/** Host words for the `labelAccessory`, read after the label and a pause: `Push, New`. */
|
|
17
|
+
labelAccessoryLabel?: string;
|
|
18
|
+
/** A neutral line under the card, announced when it changes, for progress or a hint: Registering this device. */
|
|
19
|
+
hint?: string;
|
|
10
20
|
/** Why turning it on failed, under the card: Push request timed out. It is announced when it appears. */
|
|
11
21
|
error?: string;
|
|
22
|
+
/** A secondary action under the card, such as Open Settings after the permission was refused. `feedback: false` keeps the provider's press feedback off it. */
|
|
23
|
+
action?: SettingAction;
|
|
24
|
+
}
|
|
25
|
+
/** Notifications under one optional heading: Alert types. */
|
|
26
|
+
export interface NotificationsGroup {
|
|
27
|
+
id: string;
|
|
28
|
+
title?: string;
|
|
29
|
+
items: readonly NotificationsItem[];
|
|
12
30
|
}
|
|
13
31
|
export interface NotificationsBlockProps {
|
|
14
32
|
/** Heading: Notifications. */
|
|
15
33
|
title: string;
|
|
34
|
+
/** A muted line under the header that explains the screen. */
|
|
35
|
+
description?: string;
|
|
16
36
|
/** One card each, in order. */
|
|
17
|
-
items
|
|
37
|
+
items?: readonly NotificationsItem[];
|
|
38
|
+
/** More cards under the items, in groups with an optional heading, 24dp apart. */
|
|
39
|
+
groups?: readonly NotificationsGroup[];
|
|
18
40
|
/** Shows Back on the leading edge of the header. */
|
|
19
41
|
onBack?: () => void;
|
|
20
42
|
/** A control on the trailing edge of the header, usually an IconButton. */
|
|
21
43
|
headerAction?: React.ReactNode;
|
|
44
|
+
/** Keeps the header pinned while the cards scroll: 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. */
|
|
45
|
+
stickyHeader?: boolean;
|
|
46
|
+
/** Fill behind the pinned header once content scrolls under it. Defaults to the background role; in a sheet pass the sheet's fill. */
|
|
47
|
+
stickyHeaderBackground?: string;
|
|
48
|
+
/** The scroll view used with `stickyHeader`, such as a sheet library's own. */
|
|
49
|
+
scrollComponent?: React.ComponentType<ScrollViewProps>;
|
|
22
50
|
testID?: string;
|
|
23
51
|
}
|
|
24
52
|
/** The notifications the viewer receives, as a screen: each kind is a card with a switch and a line of explanation, and a failure to turn one on reads under its card. */
|
|
25
|
-
export declare function NotificationsBlock({ title, items, onBack, headerAction, testID }: NotificationsBlockProps): React.JSX.Element;
|
|
53
|
+
export declare function NotificationsBlock({ title, description, items, groups, onBack, headerAction, stickyHeader, stickyHeaderBackground, scrollComponent, testID }: NotificationsBlockProps): React.JSX.Element;
|
|
@@ -1,14 +1,22 @@
|
|
|
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 { View } from 'react-native';
|
|
3
|
-
import { useColors } from './provider.js';
|
|
3
|
+
import { useColors, useHIG } from './provider.js';
|
|
4
4
|
import { Text } from './surface.js';
|
|
5
|
+
import { Button } from './button.js';
|
|
5
6
|
import { SettingCard, SettingHeader, SettingSwitch } from './setting-switch.js';
|
|
7
|
+
import { StickyHeaderLayout } from './sticky-header.js';
|
|
6
8
|
/** The notifications the viewer receives, as a screen: each kind is a card with a switch and a line of explanation, and a failure to turn one on reads under its card. */
|
|
7
|
-
export function NotificationsBlock({ title, items, onBack, headerAction, testID }) {
|
|
8
|
-
const colors = useColors();
|
|
9
|
-
const
|
|
9
|
+
export function NotificationsBlock({ title, description, items = [], groups, onBack, headerAction, stickyHeader, stickyHeaderBackground, scrollComponent, testID }) {
|
|
10
|
+
const colors = useColors(), { direction } = useHIG();
|
|
11
|
+
const note = { paddingHorizontal: 20, fontSize: 14, lineHeight: 21 };
|
|
12
|
+
const card = (item) => {
|
|
10
13
|
const id = `notifications-${item.id}`;
|
|
11
|
-
return _jsxs(View, { style: { gap: 8 }, children: [_jsx(SettingCard, { testID: id, children: _jsx(SettingSwitch, { testID: `${id}-switch`, label: item.label, description: item.description, checked: item.checked, disabled: item.disabled, onCheckedChange: item.onCheckedChange }) }), item.error ? _jsx(Text, { testID: `${id}-error`, accessibilityRole: 'alert', accessibilityLiveRegion: 'polite', style: { paddingHorizontal: 20, fontSize: 14, lineHeight: 21, color: colors.negative }, children: item.error }) : null] }, item.id);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
+
return _jsxs(View, { style: { gap: 8 }, children: [_jsx(SettingCard, { testID: id, children: _jsx(SettingSwitch, { testID: `${id}-switch`, label: item.label, description: item.description, checked: item.checked, disabled: item.disabled, locked: item.locked, labelAccessory: item.labelAccessory, labelAccessoryLabel: item.labelAccessoryLabel, onCheckedChange: item.onCheckedChange }) }), item.hint ? _jsx(Text, { testID: `${id}-hint`, accessibilityLiveRegion: 'polite', style: { ...note, color: colors.muted }, children: item.hint }) : null, item.error ? _jsx(Text, { testID: `${id}-error`, accessibilityRole: 'alert', accessibilityLiveRegion: 'polite', style: { paddingHorizontal: 20, fontSize: 14, lineHeight: 21, color: colors.negative }, children: item.error }) : null, item.action ? _jsx(View, { style: { marginTop: 8 }, children: _jsx(Button, { testID: `${id}-action`, intent: 'secondary', fullWidth: true, disabled: item.action.disabled, suppressFeedback: item.action.feedback === false, onPress: item.action.onSelect, children: item.action.label }) }) : null] }, item.id);
|
|
15
|
+
};
|
|
16
|
+
const cards = items.map(card);
|
|
17
|
+
const header = _jsx(SettingHeader, { testID: 'notifications', title: title, onBack: onBack, action: headerAction });
|
|
18
|
+
const body = _jsxs(_Fragment, { children: [description ? _jsx(Text, { testID: 'notifications-description', style: { fontSize: 14, lineHeight: 21, color: colors.muted, marginTop: 16, paddingHorizontal: 4 }, children: description }) : null, items.length > 0 ? _jsx(View, { testID: 'notifications-items', style: { gap: 8, marginTop: 16 }, children: cards }) : null, groups?.map(group => _jsxs(View, { testID: `notifications-group-${group.id}`, style: { gap: 8, marginTop: 24 }, children: [group.title ? _jsx(View, { style: { direction, flexDirection: 'row', alignItems: 'center', minHeight: 44, paddingStart: 4 }, children: _jsx(Text, { testID: `notifications-group-${group.id}-title`, accessibilityRole: 'header', numberOfLines: 1, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '500', color: colors.muted }, children: group.title }) }) : null, group.items.map(card)] }, group.id))] });
|
|
19
|
+
if (stickyHeader)
|
|
20
|
+
return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: 'notifications-sticky-header', header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: body });
|
|
21
|
+
return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [header, body] });
|
|
14
22
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native number display. Hermes on iOS ignores `signDisplay` (`exceptZero` drew `12.34%` where Android drew `+12.34%`), so every
|
|
3
|
+
* native figure composes its sign in HIG's own code instead of asking Intl for it: iOS and Android draw the same string, and it is
|
|
4
|
+
* the string an Intl that honours `signDisplay` draws. Display only.
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatNumber(value: number | null | undefined, locale?: string, options?: Intl.NumberFormatOptions): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { formatSignedNumber } from '@bloxwap/hig/contracts';
|
|
2
|
+
/**
|
|
3
|
+
* Native number display. Hermes on iOS ignores `signDisplay` (`exceptZero` drew `12.34%` where Android drew `+12.34%`), so every
|
|
4
|
+
* native figure composes its sign in HIG's own code instead of asking Intl for it: iOS and Android draw the same string, and it is
|
|
5
|
+
* the string an Intl that honours `signDisplay` draws. Display only.
|
|
6
|
+
*/
|
|
7
|
+
export function formatNumber(value, locale = 'en-US', options = {}) {
|
|
8
|
+
return formatSignedNumber(value, locale, options);
|
|
9
|
+
}
|
package/native/dist/pickers.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
2
|
+
import { type FlatListProps, type StyleProp, type TextInput, type TextInputProps, type ViewStyle } from 'react-native';
|
|
3
3
|
import { type SwapChain, type SwapToken, type SwapWallet } from './swap-shared.js';
|
|
4
4
|
export type { SwapChain, SwapFigure, SwapToken, SwapWallet } from './swap-shared.js';
|
|
5
|
+
/** The list component (and height animation) a sheet hands to the pickers it holds; `listComponent` on a picker block does the same for one block. */
|
|
6
|
+
export { SwapHostContext } from './swap-parts.js';
|
|
5
7
|
/** The searchable token list both pickers share. */
|
|
6
8
|
export interface PickerListProps {
|
|
7
9
|
/** Tokens offered: a wallet's holdings, a whitelist, or a whole catalog. */
|
|
@@ -18,6 +20,28 @@ export interface PickerListProps {
|
|
|
18
20
|
loading?: boolean;
|
|
19
21
|
/** Web only: focuses the search with a hardware pointer. Native never raises the keyboard on mount. */
|
|
20
22
|
autoFocus?: boolean;
|
|
23
|
+
/** `false` leaves out the search field, for a short list. Default `true`. */
|
|
24
|
+
search?: boolean;
|
|
25
|
+
/** Shows a token's balance when it is zero, where by default only a balance above zero is drawn. */
|
|
26
|
+
zeroBalances?: boolean;
|
|
27
|
+
/** A visible label over the search field, which then names it in place of the built-in label. */
|
|
28
|
+
searchLabel?: string;
|
|
29
|
+
/** A ref to the search input, for example to register it with a host bottom sheet's keyboard handling. */
|
|
30
|
+
searchRef?: React.Ref<React.ComponentRef<typeof TextInput>>;
|
|
31
|
+
/** Props for the search input, such as `onFocus`/`onBlur` for a host sheet or `returnKeyType`. The value and its change handler stay HIG's. */
|
|
32
|
+
searchInputProps?: PickerInputProps;
|
|
33
|
+
/** The list component the rows render through, such as a bottom sheet library's `FlatList`, so the list scrolls inside the host's sheet. Defaults to the `SwapHostContext` list, then React Native's `FlatList`. It receives the bounded `style` HIG sets, which the host's component may override. */
|
|
34
|
+
listComponent?: React.ComponentType<FlatListProps<SwapToken>>;
|
|
35
|
+
/** Host props for each token's row, such as `{testID: \`token-${token.id}\`}` in place of the built-in `swap-token-<id>`. HIG keeps the row's role, name, selected state and press. */
|
|
36
|
+
tokenRowProps?: (token: SwapToken) => PickerRowProps;
|
|
37
|
+
}
|
|
38
|
+
/** Host props for a picker's input: what a `TextInput` takes, except the value and its change handler. */
|
|
39
|
+
export type PickerInputProps = Omit<TextInputProps, 'value' | 'defaultValue' | 'onChangeText' | 'onChange'>;
|
|
40
|
+
/** Host props for one token row: its `testID` (replacing `swap-token-<id>`), `nativeID` and `accessibilityHint`. */
|
|
41
|
+
export interface PickerRowProps {
|
|
42
|
+
testID?: string;
|
|
43
|
+
nativeID?: string;
|
|
44
|
+
accessibilityHint?: string;
|
|
21
45
|
}
|
|
22
46
|
export interface FromPickerBlockProps extends PickerListProps {
|
|
23
47
|
/** The connected wallet. Omit for a list with no wallet row at all. */
|
|
@@ -45,13 +69,19 @@ export interface ToPickerBlockProps extends Partial<PickerListProps> {
|
|
|
45
69
|
addressPlaceholder?: string;
|
|
46
70
|
/** Shows the scan button. HIG ships no scanner: the host opens its own and writes the result to `address`. */
|
|
47
71
|
onScan?: () => void;
|
|
72
|
+
/** A visible label over the address field, which then names it in place of the built-in “Recipient”. */
|
|
73
|
+
addressLabel?: string;
|
|
74
|
+
/** A ref to the address input, for example to register it with a host bottom sheet's keyboard handling. */
|
|
75
|
+
addressRef?: React.Ref<React.ComponentRef<typeof TextInput>>;
|
|
76
|
+
/** Props for the address input, such as `onFocus`/`onBlur` for a host sheet, `textContentType` or a mono `style`. The value and its change handler stay HIG's. */
|
|
77
|
+
addressInputProps?: PickerInputProps;
|
|
48
78
|
style?: StyleProp<ViewStyle>;
|
|
49
79
|
}
|
|
50
80
|
/**
|
|
51
81
|
* Where the assets go. On its own it is a destination address field with a scan button. With `tokens` it adds the
|
|
52
82
|
* searchable token list, with the chain filter or, with `chainFilter={false}`, without it.
|
|
53
83
|
*/
|
|
54
|
-
export declare function ToPickerBlock({ address, onAddressChange, addressPlaceholder, onScan, style, tokens, onSelect, ...list }: ToPickerBlockProps): React.JSX.Element;
|
|
84
|
+
export declare function ToPickerBlock({ address, onAddressChange, addressPlaceholder, onScan, addressLabel, addressRef, addressInputProps, style, tokens, onSelect, ...list }: ToPickerBlockProps): React.JSX.Element;
|
|
55
85
|
/** @deprecated Renamed `FromPickerBlock`. The old name keeps working until the next major release. */
|
|
56
86
|
export declare const FromPicker: typeof FromPickerBlock;
|
|
57
87
|
/** @deprecated Renamed `FromPickerBlockProps`. */
|
package/native/dist/pickers.js
CHANGED
|
@@ -4,24 +4,29 @@ import { FlatList, Pressable, View, useWindowDimensions } from 'react-native';
|
|
|
4
4
|
import { useColors, useFills, useHIG, useMessages } from './provider.js';
|
|
5
5
|
import { Text } from './surface.js';
|
|
6
6
|
import { Button, IconButton } from './button.js';
|
|
7
|
-
import { Input, SearchInput } from './field.js';
|
|
7
|
+
import { Field, Input, SearchInput } from './field.js';
|
|
8
8
|
import { Filter } from './radio-group.js';
|
|
9
9
|
import { AnimatedNumberReadout } from './animated-number.js';
|
|
10
10
|
import { SwitchRow } from './switch-row.js';
|
|
11
11
|
import { LeaveIcon, LockIcon, ScanIcon, SwapHostContext, TokenIcon, WalletIcon } from './swap-parts.js';
|
|
12
12
|
import { addressColor, pickerRows, shortAddress } from './swap-shared.js';
|
|
13
|
+
/** The list component (and height animation) a sheet hands to the pickers it holds; `listComponent` on a picker block does the same for one block. */
|
|
14
|
+
export { SwapHostContext } from './swap-parts.js';
|
|
13
15
|
/** Chains present in a token list, in first-seen order. */
|
|
14
16
|
function chainsOf(tokens) { const seen = new Map(); for (const token of tokens)
|
|
15
17
|
if (!seen.has(token.chainId))
|
|
16
18
|
seen.set(token.chainId, { chainId: token.chainId, name: token.chain, icon: typeof token.chainIcon === 'string' ? token.chainIcon : undefined }); return [...seen.values()]; }
|
|
17
|
-
|
|
19
|
+
/** A row shows a known balance above zero, or a zero one when the host asks for it. */
|
|
20
|
+
const showBalance = (token, zero) => token.balance != null && Number.isFinite(token.balance) && (token.balance > 0 || (!!zero && token.balance === 0));
|
|
21
|
+
function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected = null, onSelect, loading, search = true, zeroBalances, searchLabel, searchRef, searchInputProps, listComponent, tokenRowProps, side, title }) {
|
|
18
22
|
const { direction } = useHIG();
|
|
19
23
|
const colors = useColors();
|
|
20
24
|
const fills = useFills();
|
|
21
25
|
const t = useMessages();
|
|
22
26
|
const window = useWindowDimensions();
|
|
23
|
-
// A sheet passes its backend's list through the host context so drags hand off to the sheet.
|
|
24
|
-
const
|
|
27
|
+
// A sheet passes its backend's list, through the prop or the host context, so drags hand off to the sheet.
|
|
28
|
+
const host = useContext(SwapHostContext).listComponent;
|
|
29
|
+
const List = listComponent ?? host ?? FlatList;
|
|
25
30
|
const [query, setQuery] = useState('');
|
|
26
31
|
const [chain, pickChain] = useState('');
|
|
27
32
|
const options = useMemo(() => chains ?? chainsOf(tokens), [chains, tokens]);
|
|
@@ -31,9 +36,11 @@ function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected =
|
|
|
31
36
|
const section = (heading) => _jsx(Text, { accessibilityRole: 'header', style: { paddingHorizontal: 8, paddingTop: 12, paddingBottom: 6, fontSize: 12, lineHeight: 18, fontWeight: '600', letterSpacing: 1, textTransform: 'uppercase', color: colors.muted }, children: heading });
|
|
32
37
|
const chainOptions = useMemo(() => [{ value: '', label: t.swapAllChains }, ...options.map(item => ({ value: String(item.chainId), label: item.name, icon: item.icon }))], [options, t.swapAllChains]);
|
|
33
38
|
const empty = _jsx(Text, { accessibilityLiveRegion: 'polite', testID: `swap-empty-${side}`, style: { paddingVertical: 32, textAlign: 'center', fontSize: 14, lineHeight: 21, color: colors.muted }, children: loading ? `${t.loading}…` : t.swapNoTokens });
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
// A visible label names the field through the Field context instead of the built-in name.
|
|
40
|
+
const field = _jsx(SearchInput, { ref: searchRef, accessibilityLabel: searchLabel ? undefined : t.swapSearchTokens, placeholder: t.swapSearchTokens, testID: `swap-search-${side}`, autoCapitalize: 'none', autoCorrect: false, autoComplete: 'off', spellCheck: false, ...searchInputProps, value: query, onChangeText: setQuery });
|
|
41
|
+
return _jsxs(_Fragment, { children: [search ? searchLabel ? _jsx(Field, { label: searchLabel, children: field }) : field : null, chainFilter && options.length > 1 ? _jsx(Filter, { label: t.swapChains, options: chainOptions, value: chain, onValueChange: pickChain }) : null, _jsx(List, { style: { height: Math.max(240, Math.round(window.height * 0.5)) }, data: rows, keyExtractor: token => token.id, keyboardShouldPersistTaps: 'handled', accessibilityLabel: title, testID: `swap-list-${side}`, initialNumToRender: 12, ListEmptyComponent: empty, renderItem: ({ item: token, index }) => {
|
|
42
|
+
const isSelected = selected?.id === token.id, balance = token.balance ?? 0, price = token.price ?? 0, host = tokenRowProps?.(token);
|
|
43
|
+
return _jsxs(View, { children: [hotCount > 0 && index === 0 ? section(t.swapHot) : null, hotCount > 0 && index === hotCount ? section(t.swapAllTokens) : null, _jsxs(Pressable, { nativeID: host?.nativeID, accessibilityHint: host?.accessibilityHint, accessibilityRole: 'button', accessibilityState: { selected: isSelected }, testID: host?.testID ?? `swap-token-${token.id}`, onPress: () => onSelect(token), style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', gap: 12, marginBottom: 4, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 9999, backgroundColor: pressed ? fills.well : 'transparent', opacity: isSelected ? 0.5 : 1 }), children: [_jsx(TokenIcon, { token: token }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: token.name }), _jsxs(Text, { style: { fontSize: 14, lineHeight: 21, color: colors.muted }, children: [token.detail ?? token.chain, isSelected ? ` · ${t.swapSelected}` : ''] })] }), showBalance(token, zeroBalances) ? _jsxs(View, { style: { alignItems: 'flex-end' }, children: [_jsx(AnimatedNumberReadout, { testID: `swap-token-balance-${token.id}`, value: balance, options: { maximumFractionDigits: 6 }, suffix: token.unitsSuffix, style: { fontWeight: '600', textAlign: 'right' } }), price > 0 ? _jsx(AnimatedNumberReadout, { testID: `swap-token-value-${token.id}`, value: balance * price, options: { style: 'currency', currency: 'USD' }, tone: 'muted', style: { fontSize: 14, lineHeight: 21, textAlign: 'right' } }) : null] }) : null] })] });
|
|
37
44
|
} })] });
|
|
38
45
|
}
|
|
39
46
|
/**
|
|
@@ -53,10 +60,11 @@ export function FromPickerBlock({ wallet, onConnect, onDisconnect, generateAddre
|
|
|
53
60
|
* Where the assets go. On its own it is a destination address field with a scan button. With `tokens` it adds the
|
|
54
61
|
* searchable token list, with the chain filter or, with `chainFilter={false}`, without it.
|
|
55
62
|
*/
|
|
56
|
-
export function ToPickerBlock({ address, onAddressChange, addressPlaceholder, onScan, style, tokens, onSelect, ...list }) {
|
|
63
|
+
export function ToPickerBlock({ address, onAddressChange, addressPlaceholder, onScan, addressLabel, addressRef, addressInputProps, style, tokens, onSelect, ...list }) {
|
|
57
64
|
const colors = useColors();
|
|
58
65
|
const t = useMessages();
|
|
59
|
-
|
|
66
|
+
const row = onAddressChange ? _jsxs(View, { testID: 'picker-address-row', style: { flexDirection: 'row', alignItems: 'center', gap: 8 }, children: [_jsx(View, { style: { flex: 1 }, children: _jsx(Input, { ref: addressRef, accessibilityLabel: addressLabel ? undefined : t.swapRecipient, placeholder: addressPlaceholder ?? t.swapRecipient, testID: 'picker-address', autoCapitalize: 'none', autoCorrect: false, autoComplete: 'off', spellCheck: false, ...addressInputProps, value: address ?? '', onChangeText: onAddressChange }) }), onScan ? _jsx(IconButton, { intent: 'secondary', label: t.swapScan, testID: 'picker-scan', onPress: onScan, style: { minWidth: 48, minHeight: 48 }, children: _jsx(ScanIcon, { color: colors.text }) }) : null] }) : null;
|
|
67
|
+
return _jsxs(View, { accessibilityLabel: t.swapTo, testID: 'to-picker', style: [{ gap: 16 }, style], children: [row && addressLabel ? _jsx(Field, { label: addressLabel, children: row }) : row, tokens && onSelect ? _jsx(TokenList, { ...list, tokens: tokens, onSelect: onSelect, side: 'to', title: t.swapTo }) : null] });
|
|
60
68
|
}
|
|
61
69
|
/** @deprecated Renamed `FromPickerBlock`. The old name keeps working until the next major release. */
|
|
62
70
|
export const FromPicker = FromPickerBlock;
|
|
@@ -1,25 +1,39 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
suffix?: string;
|
|
8
|
-
}
|
|
2
|
+
import { type ScrollViewProps, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import { type HeaderCloseProps, type ScreenHeaderControlProps } from './screen-header.js';
|
|
4
|
+
import { type Figure } from './figure.js';
|
|
5
|
+
/** A number the host supplies as a number so it updates place by place: `{value:0.53,options:{style:'currency',currency:'USD'}}`, or Leverage as `{value:40,suffix:'×'}`. `null` reads as unknown. `formattedValue` is the host's own text for it, still moving place by place. */
|
|
6
|
+
export type PositionBlockFigure = Figure;
|
|
9
7
|
/** One line of the summary: Notional, Fee, Liquidation. `value` is host text (`2% of profit`) or a live figure. `tone` colours the value; the default is the text colour. */
|
|
10
8
|
export interface PositionBlockDetail {
|
|
11
9
|
id?: string;
|
|
12
10
|
label: string;
|
|
13
11
|
value: string | PositionBlockFigure;
|
|
14
12
|
tone?: 'positive' | 'negative' | 'muted';
|
|
13
|
+
/** Draws the value struck through, for a charge that does not apply, and reads this host text after it: Waived. */
|
|
14
|
+
struck?: string;
|
|
15
|
+
/** Host content right after the label, such as a badge that explains the line. It may be pressable; it is then its own accessibility element. */
|
|
16
|
+
labelAccessory?: React.ReactNode;
|
|
15
17
|
}
|
|
16
|
-
/** One setting of the position: Size, Leverage, Stop Loss. With `onSelect` the row opens the host's own view and shows a chevron. */
|
|
18
|
+
/** One setting of the position: Size, Leverage, Stop Loss. With `onSelect` the row opens the host's own view and shows a chevron; with `onCheckedChange` the row is a switch. */
|
|
17
19
|
export interface PositionBlockRow {
|
|
18
20
|
id: string;
|
|
19
21
|
label: string;
|
|
20
|
-
|
|
22
|
+
/** Host text on the trailing edge, or a live figure that updates place by place. */
|
|
23
|
+
value?: string | PositionBlockFigure;
|
|
21
24
|
onSelect?: () => void;
|
|
22
25
|
disabled?: boolean;
|
|
26
|
+
/** With `onCheckedChange`, the row is a switch named by its label, and the whole row toggles it. */
|
|
27
|
+
checked?: boolean;
|
|
28
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
29
|
+
}
|
|
30
|
+
/** An action on the paper trading row's card, under the switch, such as collecting what the paper position earned. */
|
|
31
|
+
export interface PositionBlockFlagAction {
|
|
32
|
+
label: string;
|
|
33
|
+
onSelect: () => void;
|
|
34
|
+
intent?: 'primary' | 'secondary' | 'destructive';
|
|
35
|
+
busy?: boolean;
|
|
36
|
+
disabled?: boolean;
|
|
23
37
|
}
|
|
24
38
|
/** The paper trading switch. The host supplies its name, because HIG ships no trading terms. */
|
|
25
39
|
export interface PositionBlockFlag {
|
|
@@ -27,6 +41,32 @@ export interface PositionBlockFlag {
|
|
|
27
41
|
checked: boolean;
|
|
28
42
|
onCheckedChange: (checked: boolean) => void;
|
|
29
43
|
disabled?: boolean;
|
|
44
|
+
/** A button on the row's card, under the switch. */
|
|
45
|
+
action?: PositionBlockFlagAction;
|
|
46
|
+
}
|
|
47
|
+
/** The header of a PositionBlock on its own, for a host scroller that pins it: Back, the title and Close. */
|
|
48
|
+
export interface PositionBlockHeaderProps {
|
|
49
|
+
/** Heading: Position. */
|
|
50
|
+
title: string;
|
|
51
|
+
/** Shows Close on the trailing edge. */
|
|
52
|
+
onClose?: () => void;
|
|
53
|
+
/** Shows Back on the leading edge. */
|
|
54
|
+
onBack?: () => void;
|
|
55
|
+
/** A control on the trailing edge in place of Close. */
|
|
56
|
+
headerAction?: React.ReactNode;
|
|
57
|
+
/** Sets `nativeID` on the title, so a sheet around the pane can name itself with `accessibilityLabelledBy` (Android). */
|
|
58
|
+
headingId?: string;
|
|
59
|
+
/** Style of the header's container, such as padding of the host's scroller. */
|
|
60
|
+
style?: StyleProp<ViewStyle>;
|
|
61
|
+
/** Content has scrolled under the header (`useStickyHeaderScroll().scrolled`): it is transparent while false and takes `stickyHeaderBackground` while true. Omitted, the header draws no fill of its own. */
|
|
62
|
+
scrolled?: boolean;
|
|
63
|
+
/** The fill once `scrolled`. Defaults to the background role. */
|
|
64
|
+
stickyHeaderBackground?: string;
|
|
65
|
+
/** Pressable props for Back, such as `{android_disableSound: true}`. */
|
|
66
|
+
backProps?: ScreenHeaderControlProps;
|
|
67
|
+
/** Pressable props for Close; `disabled` draws it unavailable. */
|
|
68
|
+
closeProps?: HeaderCloseProps;
|
|
69
|
+
testID?: string;
|
|
30
70
|
}
|
|
31
71
|
export interface PositionBlockProps {
|
|
32
72
|
/** Heading: Position. */
|
|
@@ -45,7 +85,23 @@ export interface PositionBlockProps {
|
|
|
45
85
|
onBack?: () => void;
|
|
46
86
|
/** A control on the trailing edge of the header in place of Close. */
|
|
47
87
|
headerAction?: React.ReactNode;
|
|
88
|
+
/** Sets `nativeID` on the title, so a sheet around the pane can name itself with `accessibilityLabelledBy` (Android). */
|
|
89
|
+
headingId?: string;
|
|
90
|
+
/** Set false to leave the header out, when the host draws `PositionBlockHeader` itself, for example as a sticky header of its scroller. The two stack exactly as the whole block does. */
|
|
91
|
+
header?: boolean;
|
|
92
|
+
/** 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, such as a sheet body. */
|
|
93
|
+
stickyHeader?: boolean;
|
|
94
|
+
/** Fill behind the pinned header once content scrolls under it. Defaults to the background role; in a sheet pass the sheet's fill (`useColors().overlay`). */
|
|
95
|
+
stickyHeaderBackground?: string;
|
|
96
|
+
/** The scroll view used with `stickyHeader`, such as a sheet library's own. Defaults to React Native's ScrollView. */
|
|
97
|
+
scrollComponent?: React.ComponentType<ScrollViewProps>;
|
|
98
|
+
/** Pressable props for the header's Back, such as `{android_disableSound: true}`. */
|
|
99
|
+
backProps?: ScreenHeaderControlProps;
|
|
100
|
+
/** Pressable props for the header's Close; `disabled` draws it unavailable. */
|
|
101
|
+
closeProps?: HeaderCloseProps;
|
|
48
102
|
testID?: string;
|
|
49
103
|
}
|
|
104
|
+
/** The PositionBlock header on its own: put it in a scroller's sticky header and render `PositionBlock` with `header={false}` under it. It carries the block's top and side padding. */
|
|
105
|
+
export declare function PositionBlockHeader({ style, testID, scrolled, stickyHeaderBackground, ...props }: PositionBlockHeaderProps): React.JSX.Element;
|
|
50
106
|
/** The position being opened or edited as a screen: a summary of what it costs and where it ends, an optional paper trading switch, and its settings as grouped rows that open the host's own views. */
|
|
51
|
-
export declare function PositionBlock({ title, details, note, paperTrade, groups, onClose, onBack, headerAction, testID }: PositionBlockProps): React.JSX.Element;
|
|
107
|
+
export declare function PositionBlock({ title, details, note, paperTrade, groups, onClose, onBack, headerAction, headingId, header, stickyHeader, stickyHeaderBackground, scrollComponent, backProps, closeProps, testID }: PositionBlockProps): React.JSX.Element;
|