@bloxwap/hig 0.7.0 → 0.9.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 +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 +29 -2
- package/contracts/dist/index.js +123 -4
- package/contracts/dist/invariants.d.ts +17 -0
- package/contracts/dist/invariants.js +24 -0
- package/contracts/dist/login.d.ts +34 -0
- package/contracts/dist/login.js +43 -0
- package/contracts/dist/messages.d.ts +57 -3
- package/contracts/dist/messages.js +20 -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 +10 -1
- package/native/dist/account-block.js +17 -7
- package/native/dist/animated-number-model.d.ts +41 -1
- package/native/dist/animated-number-model.js +201 -23
- package/native/dist/animated-number.d.ts +39 -1
- package/native/dist/animated-number.js +164 -17
- package/native/dist/announce.d.ts +2 -0
- package/native/dist/announce.js +10 -0
- package/native/dist/asset-balance-row.d.ts +3 -1
- package/native/dist/asset-balance-row.js +15 -4
- 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 +2 -0
- package/native/dist/bar-mark.js +4 -2
- package/native/dist/bar-pnl.js +2 -1
- package/native/dist/blocks.d.ts +9 -2
- package/native/dist/blocks.js +8 -1
- package/native/dist/brand.js +2 -1
- package/native/dist/button.d.ts +7 -2
- package/native/dist/button.js +13 -3
- 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 +5 -1
- package/native/dist/deposit-block.d.ts +19 -0
- package/native/dist/deposit-block.js +17 -0
- package/native/dist/explainer-block.d.ts +91 -0
- package/native/dist/explainer-block.js +34 -0
- package/native/dist/field.d.ts +5 -1
- package/native/dist/field.js +27 -6
- 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 +10 -1
- package/native/dist/language-block.js +11 -4
- package/native/dist/list-group.d.ts +3 -1
- package/native/dist/list-group.js +26 -13
- package/native/dist/login-block.d.ts +4 -0
- package/native/dist/login-block.js +22 -0
- package/native/dist/manage-position-block.d.ts +8 -1
- package/native/dist/manage-position-block.js +7 -2
- package/native/dist/market-row.js +19 -8
- package/native/dist/navigation.js +5 -3
- package/native/dist/number-format.d.ts +6 -0
- package/native/dist/number-format.js +9 -0
- package/native/dist/pickers.d.ts +8 -0
- package/native/dist/pickers.js +3 -3
- package/native/dist/position-block.d.ts +5 -5
- 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 +10 -1
- package/native/dist/profile-block.js +8 -3
- package/native/dist/provider.d.ts +5 -2
- package/native/dist/provider.js +27 -5
- package/native/dist/qr-code.d.ts +33 -0
- package/native/dist/qr-code.js +29 -0
- package/native/dist/radio-group.d.ts +19 -7
- package/native/dist/radio-group.js +39 -10
- package/native/dist/reward-block.d.ts +10 -7
- package/native/dist/reward-block.js +9 -4
- package/native/dist/screen-header.d.ts +13 -3
- package/native/dist/screen-header.js +12 -4
- package/native/dist/select.js +4 -2
- package/native/dist/selection.d.ts +2 -1
- package/native/dist/selection.js +1 -0
- package/native/dist/setting-switch.d.ts +1 -1
- package/native/dist/setting-switch.js +7 -3
- package/native/dist/slider.js +5 -1
- package/native/dist/sound-haptics-block.js +1 -1
- package/native/dist/status.d.ts +41 -9
- package/native/dist/status.js +34 -17
- package/native/dist/sticky-header.js +9 -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 → swap-block.d.ts} +18 -8
- package/native/dist/{swap-panel-block.js → swap-block.js} +63 -35
- package/native/dist/swap-parts.d.ts +3 -10
- package/native/dist/swap-parts.js +22 -24
- package/native/dist/swap-shared.d.ts +2 -2
- package/native/dist/swap-shared.js +10 -6
- package/native/dist/swap-sheet.d.ts +3 -3
- package/native/dist/swap-sheet.js +3 -3
- package/native/dist/swap-views.js +1 -1
- package/native/dist/target-block.d.ts +7 -1
- package/native/dist/target-block.js +13 -6
- package/native/dist/toast.d.ts +47 -0
- package/native/dist/toast.js +386 -0
- package/native/dist/token-action-block.d.ts +11 -2
- package/native/dist/token-action-block.js +10 -4
- package/native/dist/trade-history-list-block.js +7 -4
- package/native/dist/wallet-address-core.js +6 -3
- package/native-fonts/README.md +1 -1
- package/og-fonts/README.md +1 -1
- package/package.json +155 -11
- 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 +18 -0
- package/react/dist/animated-number-model.js +75 -5
- package/react/dist/animated-number.d.ts +45 -1
- package/react/dist/animated-number.js +137 -6
- package/react/dist/asset-balance-row.d.ts +3 -1
- package/react/dist/asset-balance-row.js +10 -4
- 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/blocks/account-block.d.ts +5 -1
- package/react/dist/blocks/account-block.js +11 -6
- 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/deposit-block.d.ts +19 -0
- package/react/dist/blocks/deposit-block.js +15 -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 +5 -1
- package/react/dist/blocks/language-block.js +4 -3
- package/react/dist/blocks/login-block.d.ts +4 -0
- package/react/dist/blocks/login-block.js +14 -0
- package/react/dist/blocks/manage-position-block.d.ts +3 -1
- package/react/dist/blocks/manage-position-block.js +2 -2
- package/react/dist/blocks/market-row.js +8 -3
- package/react/dist/blocks/notifications-block.d.ts +3 -1
- package/react/dist/blocks/notifications-block.js +2 -2
- package/react/dist/blocks/pickers.d.ts +9 -0
- package/react/dist/blocks/pickers.js +4 -2
- package/react/dist/blocks/position-block.d.ts +3 -3
- 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 +5 -1
- package/react/dist/blocks/profile-block.js +12 -13
- package/react/dist/blocks/reward-block.d.ts +13 -8
- package/react/dist/blocks/reward-block.js +7 -4
- package/react/dist/blocks/screen-header.d.ts +10 -2
- package/react/dist/blocks/screen-header.js +7 -4
- package/react/dist/blocks/setting-switch.js +6 -3
- package/react/dist/blocks/signals-block.d.ts +3 -1
- package/react/dist/blocks/signals-block.js +4 -3
- package/react/dist/blocks/sound-haptics-block.d.ts +3 -1
- package/react/dist/blocks/sound-haptics-block.js +2 -2
- package/react/dist/blocks/sticky-header.d.ts +14 -4
- package/react/dist/blocks/sticky-header.js +68 -8
- package/react/dist/blocks/swap/settings.js +2 -1
- package/react/dist/blocks/swap/shared.d.ts +22 -22
- package/react/dist/blocks/swap/shared.js +30 -28
- package/react/dist/blocks/{swap-panel-block.d.ts → swap-block.d.ts} +19 -8
- package/react/dist/blocks/swap-block.js +215 -0
- package/react/dist/blocks/swap-sheet.d.ts +3 -3
- package/react/dist/blocks/swap-sheet.js +3 -3
- package/react/dist/blocks/target-block.d.ts +7 -1
- package/react/dist/blocks/target-block.js +10 -4
- package/react/dist/blocks/token-action-block.d.ts +6 -2
- package/react/dist/blocks/token-action-block.js +3 -2
- package/react/dist/blocks/trade-history-detail-block.d.ts +3 -1
- package/react/dist/blocks/trade-history-detail-block.js +2 -2
- package/react/dist/blocks/trade-history-list-block.d.ts +3 -1
- package/react/dist/blocks/trade-history-list-block.js +7 -4
- package/react/dist/blocks.d.ts +8 -2
- package/react/dist/blocks.js +7 -1
- package/react/dist/brand.js +2 -1
- package/react/dist/button.d.ts +9 -3
- package/react/dist/button.js +8 -3
- package/react/dist/confetti.d.ts +27 -0
- package/react/dist/confetti.js +240 -0
- package/react/dist/data.js +8 -1
- package/react/dist/field.d.ts +6 -1
- package/react/dist/field.js +18 -9
- package/react/dist/gesture-sheet.d.ts +15 -1
- package/react/dist/gesture-sheet.js +53 -8
- package/react/dist/list-group.js +11 -7
- package/react/dist/navigation.js +11 -3
- package/react/dist/overlay.d.ts +1 -4
- package/react/dist/overlay.js +1 -3
- package/react/dist/popover.d.ts +30 -0
- package/react/dist/popover.js +34 -0
- package/react/dist/preset-group.d.ts +30 -0
- package/react/dist/preset-group.js +13 -0
- package/react/dist/provider.d.ts +2 -2
- package/react/dist/provider.js +23 -6
- 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 +13 -5
- package/react/dist/selection.js +13 -8
- 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 +260 -165
- package/react/dist/toast.d.ts +19 -12
- package/react/dist/toast.js +29 -7
- package/react/dist/wallet-address-core.d.ts +8 -4
- package/react/dist/wallet-address-core.js +10 -5
- package/tokens/README.md +2 -2
- package/tokens/assets/onramps/apple-pay.svg +33 -0
- package/tokens/assets/onramps/bank.svg +98 -0
- package/tokens/assets/onramps/blink.svg +37 -0
- package/tokens/assets/onramps/cashapp.svg +33 -0
- package/tokens/assets/onramps/crypto.svg +121 -0
- package/tokens/assets/onramps/exchange.svg +105 -0
- package/tokens/dist/deposit-icons.d.ts +1 -0
- package/tokens/dist/deposit-icons.js +28 -0
- 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
- package/react/dist/blocks/swap-panel-block.js +0 -178
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check as SharedCheck } from '@bloxwap/icons/native/check';
|
|
3
|
+
import { ArrowUpRight } from '@bloxwap/icons/native/arrow-up-right';
|
|
2
4
|
import React, { forwardRef, useState } from 'react';
|
|
3
|
-
import { ActivityIndicator, Platform, Pressable, View } from 'react-native';
|
|
5
|
+
import { ActivityIndicator, Platform, Pressable, Text as NativeText, View } from 'react-native';
|
|
4
6
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
7
|
import { useColors, useFills, useHIG } from './provider.js';
|
|
6
8
|
import { Text } from './surface.js';
|
|
@@ -8,6 +10,9 @@ import { ChevronIcon } from './icons.js';
|
|
|
8
10
|
import { SwitchRow } from './switch-row.js';
|
|
9
11
|
import { plainText } from './text-content.js';
|
|
10
12
|
const shown = (node) => node != null && node !== false && node !== '';
|
|
13
|
+
const bare = (node) => typeof node === 'string' || typeof node === 'number';
|
|
14
|
+
/** A fragment or array with a bare string or number among its children (through nested fragments and arrays). */
|
|
15
|
+
const loose = (node) => Array.isArray(node) ? node.some(child => bare(child) || loose(child)) : React.isValidElement(node) && node.type === React.Fragment && loose([].concat(node.props.children));
|
|
11
16
|
const actionSlop = { top: 12, bottom: 12, left: 8, right: 8 };
|
|
12
17
|
/** A grouped list for menus and settings: an optional heading over rows that share one rounded container. */
|
|
13
18
|
export function ListGroup({ title, titleAccessory, action, intro, children, testID }) {
|
|
@@ -32,33 +37,41 @@ export function ListGroup({ title, titleAccessory, action, intro, children, test
|
|
|
32
37
|
}
|
|
33
38
|
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
34
39
|
/** The check of a selected row. It does not mirror in right-to-left layouts. */
|
|
35
|
-
function Check({ color, testID }) { return _jsx(
|
|
40
|
+
function Check({ color, testID }) { return _jsx(SharedCheck, { size: 20, color: color, testID: testID }); }
|
|
36
41
|
/** An arrow pointing up and away, for a row that opens something outside the app; it mirrors in right-to-left layouts. */
|
|
37
|
-
function External({ color, rtl, testID }) {
|
|
38
|
-
return _jsxs(View, { ...hidden, testID: testID, style: { width: 20, height: 20, alignItems: 'center', justifyContent: 'center', transform: rtl ? [{ scaleX: -1 }] : undefined }, children: [_jsx(View, { style: { position: 'absolute', width: 12, height: 1.75, borderRadius: 1, backgroundColor: color, transform: [{ rotate: '-45deg' }] } }), _jsx(View, { style: { position: 'absolute', top: 5, right: 5, width: 7, height: 7, borderTopWidth: 1.75, borderRightWidth: 1.75, borderColor: color } })] });
|
|
39
|
-
}
|
|
42
|
+
function External({ color, rtl, testID }) { return _jsx(ArrowUpRight, { size: 20, color: color, testID: testID, style: { transform: rtl ? [{ scaleX: -1 }] : undefined } }); }
|
|
40
43
|
/** One row of a ListGroup: the label leads; a value, icons, a badge or a control trail. With `onSelect` the whole row is one button and shows a disclosure chevron; with `checked` or `onCheckedChange` the whole row is a switch; otherwise the row is static, so a control in `trailing` is its only target. Other Pressable props, such as `android_disableSound`, `hitSlop` or `onLongPress`, reach the row, and the ref reaches its view. */
|
|
41
|
-
export const ListRow = /* @__PURE__ */ forwardRef(function ListRow({ label, description, tone, leading, value, valueLabel, valueTone, trailing, onSelect, disabled, selected, busy, busyLabel, disclosure, checked, defaultChecked, onCheckedChange, testID, ...rest }, ref) {
|
|
44
|
+
export const ListRow = /* @__PURE__ */ forwardRef(function ListRow({ label, description, accessibilityLabel, tone, leading, value, valueLabel, valueTone, trailing, onSelect, disabled, selected, busy, busyLabel, disclosure, checked, defaultChecked, onCheckedChange, testID, ...rest }, ref) {
|
|
42
45
|
const colors = useColors(), fills = useFills(), { direction, messages } = useHIG();
|
|
43
46
|
const [internal, setInternal] = useState(!!defaultChecked);
|
|
44
47
|
const toggles = !onSelect && (checked !== undefined || defaultChecked !== undefined || onCheckedChange != null);
|
|
45
48
|
const row = (pressed) => ({ flexDirection: 'row', alignItems: 'flex-start', gap: 12, minHeight: 56, paddingVertical: 8, paddingHorizontal: 20, backgroundColor: pressed ? fills.raised : fills.well, opacity: disabled ? 0.5 : 1 });
|
|
46
49
|
const text = typeof value === 'string' || typeof value === 'number';
|
|
47
50
|
const described = shown(description), about = described ? plainText(description) : '';
|
|
48
|
-
const reading = [label, about || null, text ? String(value) : valueLabel ?? null].filter(Boolean).join(', ');
|
|
51
|
+
const reading = accessibilityLabel ?? [label, about || null, text ? String(value) : valueLabel ?? null].filter(Boolean).join(', ');
|
|
49
52
|
const busyText = busyLabel ?? messages.busy ?? en.busy;
|
|
50
53
|
const spoken = busy && busyText && Platform.OS !== 'android' ? `${reading} · ${busyText}` : reading;
|
|
51
54
|
// Everything aligns to the first line of the label, so a trailing switch stays at the top when the label wraps.
|
|
52
55
|
const first = { minHeight: 40, justifyContent: 'center' };
|
|
53
56
|
// A static row with a state is one element, so the state is read; a trailing control keeps the row open so the control stays its own target.
|
|
54
|
-
|
|
55
|
-
const
|
|
57
|
+
// A host name on a static row: with no trailing control the row is one element; with one, the text is one element beside it.
|
|
58
|
+
const named = !onSelect && !toggles && accessibilityLabel !== undefined;
|
|
59
|
+
const announced = !onSelect && !toggles && (selected !== undefined || !!busy || named) && trailing == null;
|
|
60
|
+
const grouped = named && trailing != null;
|
|
61
|
+
const quiet = onSelect || toggles || announced ? hidden : {}, textQuiet = grouped ? hidden : quiet;
|
|
56
62
|
const lead = leading == null ? null : _jsx(View, { ...hidden, style: first, children: leading });
|
|
57
63
|
const labelColor = tone === 'destructive' ? colors.negative : tone === 'muted' ? colors.muted : colors.text;
|
|
64
|
+
const descriptionStyle = { fontSize: 14, lineHeight: 20, color: colors.muted };
|
|
65
|
+
// Text, one Text element, or a fragment or array holding bare text (`<>Ends in <Text>3m</Text></>`) keeps the muted line, since a bare string cannot sit in a View; richer host content is laid out as given.
|
|
66
|
+
const inline = bare(description) || loose(description) || (React.isValidElement(description) && (description.type === Text || description.type === NativeText));
|
|
67
|
+
const descriptionTestID = testID ? `${testID}-description` : undefined;
|
|
68
|
+
const nameBox = { flex: 1, flexShrink: 1, minWidth: 0, paddingVertical: 8 };
|
|
69
|
+
const nameRole = grouped ? { accessible: true, accessibilityLabel } : quiet;
|
|
58
70
|
const name = described
|
|
59
|
-
? _jsxs(View, { ...
|
|
60
|
-
: _jsx(
|
|
61
|
-
|
|
71
|
+
? _jsxs(View, { ...nameRole, style: nameBox, children: [_jsx(Text, { style: { fontSize: 16, lineHeight: 24, color: labelColor }, children: label }), inline ? _jsx(Text, { testID: descriptionTestID, style: descriptionStyle, children: description }) : _jsx(View, { testID: descriptionTestID, style: { minWidth: 0 }, children: description })] })
|
|
72
|
+
: grouped ? _jsx(View, { ...nameRole, style: nameBox, children: _jsx(Text, { style: { fontSize: 16, lineHeight: 24, color: labelColor }, children: label }) })
|
|
73
|
+
: _jsx(Text, { ...textQuiet, style: { ...nameBox, fontSize: 16, lineHeight: 24, color: labelColor }, children: label });
|
|
74
|
+
const amount = value == null || value === false ? null : text ? _jsx(Text, { ...textQuiet, testID: testID ? `${testID}-value` : undefined, numberOfLines: 1, style: { flexShrink: 1, maxWidth: '50%', paddingVertical: 8, fontSize: 16, lineHeight: 24, color: colors[valueTone ?? 'muted'], textAlign: 'right' }, children: value }) : _jsx(View, { ...(grouped ? hidden : !onSelect && !toggles && !announced && valueLabel ? { accessible: true, accessibilityLabel: valueLabel } : {}), style: first, children: value });
|
|
62
75
|
const extra = trailing == null ? null : _jsx(View, { pointerEvents: onSelect || toggles ? 'none' : 'auto', ...quiet, style: { flexDirection: 'row', alignItems: 'center', gap: 8, minHeight: 40 }, children: trailing });
|
|
63
76
|
const chevron = _jsx(View, { testID: testID ? `${testID}-chevron` : undefined, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) });
|
|
64
77
|
const glyphKind = disclosure ?? (selected !== undefined ? 'none' : 'chevron');
|
|
@@ -70,7 +83,7 @@ export const ListRow = /* @__PURE__ */ forwardRef(function ListRow({ label, desc
|
|
|
70
83
|
const on = checked ?? internal;
|
|
71
84
|
const hint = [about || null, text ? String(value) : valueLabel ?? null].filter(Boolean).join(', ') || undefined;
|
|
72
85
|
// The row holds an uncontrolled state itself so the drawn track follows it; SwitchRow stays controlled and emits feedback once.
|
|
73
|
-
return _jsx(SwitchRow, { ...rest, ref: ref, testID: testID, label: label, accessibilityHint: rest.accessibilityHint ?? hint, accessibilityState: busy ? { busy: true } : undefined, checked: on, disabled: disabled || busy, onCheckedChange: next => { if (checked === undefined)
|
|
86
|
+
return _jsx(SwitchRow, { ...rest, ref: ref, testID: testID, label: accessibilityLabel ?? label, accessibilityHint: rest.accessibilityHint ?? hint, accessibilityState: busy ? { busy: true } : undefined, checked: on, disabled: disabled || busy, onCheckedChange: next => { if (checked === undefined)
|
|
74
87
|
setInternal(next); onCheckedChange?.(next); }, style: row(false), children: _jsx(SwitchRowContent, { first: first, lead: lead, name: name, amount: amount, extra: extra, checked: on, testID: testID }) });
|
|
75
88
|
}
|
|
76
89
|
const state = { ...(selected !== undefined ? { selected } : {}), ...(busy ? { busy: true } : {}) };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type LoginBlockProps } from '@bloxwap/hig/contracts/login';
|
|
3
|
+
export type { LoginBlockProps, LoginProvider } from '@bloxwap/hig/contracts/login';
|
|
4
|
+
export declare function LoginBlock({ onLogin, onClose, lastUsed, disabled, analyticsEnabled, onAnalyticsChange, labels, termsUrl, privacyUrl }: LoginBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import Svg, { Path } from 'react-native-svg';
|
|
5
|
+
import { HeaderClose, ScreenHeader } from './screen-header.js';
|
|
6
|
+
import { Switch } from './switch.js';
|
|
7
|
+
import { Dialog } from './overlay.js';
|
|
8
|
+
import { SeverityIcon } from './icons.js';
|
|
9
|
+
import { ListRow } from './list-group.js';
|
|
10
|
+
import { Badge } from './status.js';
|
|
11
|
+
import { Text } from './surface.js';
|
|
12
|
+
import { Button, Link } from './button.js';
|
|
13
|
+
import { useColors } from './provider.js';
|
|
14
|
+
import { loginProviders, loginArtwork, loginCopy, loginTermsUrl, loginPrivacyUrl } from '@bloxwap/hig/contracts/login';
|
|
15
|
+
export function LoginBlock({ onLogin, onClose, lastUsed, disabled, analyticsEnabled, onAnalyticsChange, labels, termsUrl = loginTermsUrl, privacyUrl = loginPrivacyUrl }) {
|
|
16
|
+
const copy = { ...loginCopy, ...labels };
|
|
17
|
+
const colors = useColors();
|
|
18
|
+
const [infoOpen, setInfoOpen] = React.useState(false);
|
|
19
|
+
const infoTrigger = React.useRef(null);
|
|
20
|
+
const linkStyle = { color: colors.muted, textDecorationLine: 'underline' };
|
|
21
|
+
return _jsxs(View, { style: { gap: 16 }, children: [_jsx(ScreenHeader, { title: copy.title, action: _jsx(HeaderClose, { label: copy.close, onClose: onClose }) }), _jsx(View, { style: { gap: 8 }, children: loginProviders.map(provider => _jsx(View, { style: { borderRadius: 16, overflow: 'hidden' }, children: _jsx(ListRow, { label: copy[provider], disabled: disabled, disclosure: "none", onSelect: () => onLogin(provider), leading: _jsx(Svg, { width: 20, height: 20, viewBox: "0 0 24 24", children: loginArtwork[provider].map(path => _jsx(Path, { d: path.d, fill: path.fill ?? colors.text }, path.d)) }), accessibilityLabel: lastUsed === provider ? `${copy[provider]}, ${copy.lastUsed}` : copy[provider], trailing: lastUsed === provider ? _jsx(Badge, { tone: "positive", children: copy.lastUsed }) : undefined }) }, provider)) }), _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center' }, children: [_jsx(Text, { style: { flexShrink: 1 }, children: copy.analytics }), _jsx(Button, { ref: infoTrigger, intent: "ghost", contentMode: "custom", accessibilityLabel: copy.analyticsInfo, style: { width: 44, paddingHorizontal: 0 }, onPress: () => setInfoOpen(true), children: _jsx(SeverityIcon, { kind: "info", color: colors.muted }) }), _jsx(View, { style: { marginStart: 'auto' }, children: _jsx(Switch, { hideLabel: true, label: copy.analytics, checked: analyticsEnabled, onCheckedChange: onAnalyticsChange }) })] }), _jsx(Dialog, { open: infoOpen, onOpenChange: setInfoOpen, title: copy.analyticsInfo, closeLabel: copy.close, returnFocusRef: infoTrigger, children: _jsx(Text, { children: copy.description }) }), _jsxs(View, { style: { flexDirection: 'row', justifyContent: 'center', flexWrap: 'wrap', gap: 16 }, children: [_jsx(Link, { href: termsUrl, contentMode: "custom", children: _jsx(Text, { style: linkStyle, children: copy.terms }) }), _jsx(Link, { href: privacyUrl, contentMode: "custom", children: _jsx(Text, { style: linkStyle, children: copy.privacy }) })] })] });
|
|
22
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type ScrollViewProps } from 'react-native';
|
|
2
3
|
import { type Figure } from './figure.js';
|
|
3
4
|
import type { AssetArtwork } from './asset-balance-row.js';
|
|
4
5
|
export type { AssetArtwork } from './asset-balance-row.js';
|
|
@@ -77,6 +78,12 @@ export interface ManagePositionBlockProps {
|
|
|
77
78
|
headerAction?: React.ReactNode;
|
|
78
79
|
/** Sets `nativeID` on the title, so a sheet around the pane can name itself with `accessibilityLabelledBy` (Android). */
|
|
79
80
|
headingId?: string;
|
|
81
|
+
/** 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. */
|
|
82
|
+
stickyHeader?: boolean;
|
|
83
|
+
/** With `stickyHeader`: the header's fill once content is under it. Defaults to the background role; in a sheet pass the sheet's fill. */
|
|
84
|
+
stickyHeaderBackground?: string;
|
|
85
|
+
/** The scroll view used with `stickyHeader`, such as a sheet library's own. Defaults to React Native's ScrollView. */
|
|
86
|
+
scrollComponent?: React.ComponentType<ScrollViewProps>;
|
|
80
87
|
testID?: string;
|
|
81
88
|
}
|
|
82
89
|
/** Distance left before liquidation. `total` is the span from entry to liquidation, `buffer` how much of it remains between mark and liquidation (the whole span while in profit), `drawdown` the rest, and `share` the buffer as a fraction of the span. Unknown mark or liquidation, or a liquidation on the wrong side of entry, gives zeros and a `null` share. */
|
|
@@ -92,4 +99,4 @@ export declare function positionCorridor({ side, entry, mark, liquidation }: {
|
|
|
92
99
|
share: number | null;
|
|
93
100
|
};
|
|
94
101
|
/** 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. */
|
|
95
|
-
export declare function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, testID }: ManagePositionBlockProps): React.JSX.Element;
|
|
102
|
+
export declare function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, stickyHeader, stickyHeaderBackground, scrollComponent, testID }: ManagePositionBlockProps): React.JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { Image, Pressable, View } from 'react-native';
|
|
4
|
+
import { StickyHeaderLayout } from './sticky-header.js';
|
|
4
5
|
import { useColors, useFills, useHIG, useMessages, useNumberLocale, usePresentNumber } from './provider.js';
|
|
5
6
|
import { Text } from './surface.js';
|
|
6
7
|
import { IconButton } from './button.js';
|
|
@@ -38,7 +39,7 @@ function Sentence({ template, text, value, options, suffix, testID }) {
|
|
|
38
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] });
|
|
39
40
|
}
|
|
40
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. */
|
|
41
|
-
export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, testID }) {
|
|
42
|
+
export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, stickyHeader, stickyHeaderBackground, scrollComponent, testID }) {
|
|
42
43
|
const colors = useColors(), fills = useFills(), t = useMessages(), { direction } = useHIG(), locale = useNumberLocale(), present = usePresentNumber();
|
|
43
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.
|
|
44
45
|
const [broken, setBroken] = useState(null);
|
|
@@ -78,5 +79,9 @@ export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidati
|
|
|
78
79
|
return { value: figure, valueTone: action.tone };
|
|
79
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)) };
|
|
80
81
|
};
|
|
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] });
|
|
82
87
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check } from '@bloxwap/icons/native/check';
|
|
2
3
|
import { forwardRef } from 'react';
|
|
3
4
|
import { View } from 'react-native';
|
|
4
5
|
import { useColors, useFills } from './provider.js';
|
|
@@ -11,20 +12,30 @@ const hidden = { accessible: false, accessibilityElementsHidden: true, important
|
|
|
11
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) {
|
|
12
13
|
const colors = useColors(), fills = useFills();
|
|
13
14
|
const label = `${name} (${symbol})`;
|
|
14
|
-
|
|
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] });
|
|
15
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 };
|
|
16
22
|
const title = mode === 'presentation'
|
|
17
|
-
? _jsx(View, { style: disabled ? { opacity: 0.5,
|
|
18
|
-
: 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' }, children: lines })
|
|
19
|
-
: _jsx(Button, { intent: 'ghost', accessibilityState: selected ? { selected: true } : undefined, disabled: disabled, onPress: onSelect, onPressIn: onPressIn, testID: testID ? `${testID}-select` : undefined, children: label });
|
|
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 }) });
|
|
20
26
|
const leading = favorite !== undefined || icon !== undefined;
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
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] });
|
|
24
35
|
const plain = !ref && !leading && detail === undefined && price !== undefined && change !== undefined && volume === undefined && trailing == null && !selected && !disabled && !active && !onPressIn && mode === 'action' && !testID && !style;
|
|
25
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.
|
|
26
37
|
if (plain)
|
|
27
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 })] });
|
|
28
39
|
const state = mode === 'presentation' && (selected || disabled) ? { ...(selected ? { selected: true } : {}), ...(disabled ? { disabled: true } : {}) } : undefined;
|
|
29
|
-
return _jsx(View, { ref: ref, testID: testID, accessibilityState: state, style: [{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', flexWrap: '
|
|
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 });
|
|
30
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 }); }
|
|
@@ -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
|
@@ -32,9 +32,17 @@ export interface PickerListProps {
|
|
|
32
32
|
searchInputProps?: PickerInputProps;
|
|
33
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
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;
|
|
35
37
|
}
|
|
36
38
|
/** Host props for a picker's input: what a `TextInput` takes, except the value and its change handler. */
|
|
37
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;
|
|
45
|
+
}
|
|
38
46
|
export interface FromPickerBlockProps extends PickerListProps {
|
|
39
47
|
/** The connected wallet. Omit for a list with no wallet row at all. */
|
|
40
48
|
wallet?: SwapWallet;
|
package/native/dist/pickers.js
CHANGED
|
@@ -18,7 +18,7 @@ function chainsOf(tokens) { const seen = new Map(); for (const token of tokens)
|
|
|
18
18
|
seen.set(token.chainId, { chainId: token.chainId, name: token.chain, icon: typeof token.chainIcon === 'string' ? token.chainIcon : undefined }); return [...seen.values()]; }
|
|
19
19
|
/** A row shows a known balance above zero, or a zero one when the host asks for it. */
|
|
20
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, side, title }) {
|
|
21
|
+
function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected = null, onSelect, loading, search = true, zeroBalances, searchLabel, searchRef, searchInputProps, listComponent, tokenRowProps, side, title }) {
|
|
22
22
|
const { direction } = useHIG();
|
|
23
23
|
const colors = useColors();
|
|
24
24
|
const fills = useFills();
|
|
@@ -39,8 +39,8 @@ function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected =
|
|
|
39
39
|
// A visible label names the field through the Field context instead of the built-in name.
|
|
40
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
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;
|
|
43
|
-
return _jsxs(View, { children: [hotCount > 0 && index === 0 ? section(t.swapHot) : null, hotCount > 0 && index === hotCount ? section(t.swapAllTokens) : null, _jsxs(Pressable, { accessibilityRole: 'button', accessibilityState: { selected: isSelected }, testID: `swap-token-${token.id}`, onPress: () => onSelect(token), style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', gap: 12, marginBottom: 4, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 9999, backgroundColor: pressed ? fills.well : 'transparent', opacity: isSelected ? 0.5 : 1 }), children: [_jsx(TokenIcon, { token: token }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: token.name }), _jsxs(Text, { style: { fontSize: 14, lineHeight: 21, color: colors.muted }, children: [token.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] })] });
|
|
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] })] });
|
|
44
44
|
} })] });
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type ScrollViewProps, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
-
import { type ScreenHeaderControlProps } from './screen-header.js';
|
|
3
|
+
import { type HeaderCloseProps, type ScreenHeaderControlProps } from './screen-header.js';
|
|
4
4
|
import { type Figure } from './figure.js';
|
|
5
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
6
|
export type PositionBlockFigure = Figure;
|
|
@@ -64,8 +64,8 @@ export interface PositionBlockHeaderProps {
|
|
|
64
64
|
stickyHeaderBackground?: string;
|
|
65
65
|
/** Pressable props for Back, such as `{android_disableSound: true}`. */
|
|
66
66
|
backProps?: ScreenHeaderControlProps;
|
|
67
|
-
/** Pressable props for Close. */
|
|
68
|
-
closeProps?:
|
|
67
|
+
/** Pressable props for Close; `disabled` draws it unavailable. */
|
|
68
|
+
closeProps?: HeaderCloseProps;
|
|
69
69
|
testID?: string;
|
|
70
70
|
}
|
|
71
71
|
export interface PositionBlockProps {
|
|
@@ -97,8 +97,8 @@ export interface PositionBlockProps {
|
|
|
97
97
|
scrollComponent?: React.ComponentType<ScrollViewProps>;
|
|
98
98
|
/** Pressable props for the header's Back, such as `{android_disableSound: true}`. */
|
|
99
99
|
backProps?: ScreenHeaderControlProps;
|
|
100
|
-
/** Pressable props for the header's Close. */
|
|
101
|
-
closeProps?:
|
|
100
|
+
/** Pressable props for the header's Close; `disabled` draws it unavailable. */
|
|
101
|
+
closeProps?: HeaderCloseProps;
|
|
102
102
|
testID?: string;
|
|
103
103
|
}
|
|
104
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. */
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
/** One quick choice. `testID` is the chip's test ID; without it the chip takes `<group testID>-<value>`. */
|
|
4
|
+
export interface PresetOption<T extends string | number = string> {
|
|
5
|
+
value: T;
|
|
6
|
+
label: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
testID?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface PresetGroupProps<T extends string | number = string> {
|
|
11
|
+
/** Accessible name of the group; not drawn, so a heading or row above it names it on screen. Native reads it as each chip's hint, after the chip's own label and state. */
|
|
12
|
+
label?: string;
|
|
13
|
+
options: readonly PresetOption<T>[];
|
|
14
|
+
/** The selected choice; `null` selects none. Omit it, with `defaultValue`, to let the group keep its own selection. */
|
|
15
|
+
value?: T | null;
|
|
16
|
+
defaultValue?: T | null;
|
|
17
|
+
/** Called with the choice taken. A press on the selected chip, or on a dimmed one, does nothing. */
|
|
18
|
+
onValueChange?: (value: T) => void;
|
|
19
|
+
/** Chips per row. Defaults to every option in one row; with fewer columns the chips wrap onto equal-width rows. */
|
|
20
|
+
columns?: number;
|
|
21
|
+
/** Fill of the selected chip. Defaults to `primary`; TargetBlock passes `destructive` for a stop loss. */
|
|
22
|
+
selectedIntent?: 'primary' | 'destructive' | 'up' | 'down';
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/** Keeps the provider's `selection` feedback off this group, for a host that plays its own cue. By default a new choice plays it like a SegmentedControl. */
|
|
25
|
+
suppressFeedback?: boolean;
|
|
26
|
+
/** Layout of the group, such as a top margin. */
|
|
27
|
+
style?: StyleProp<ViewStyle>;
|
|
28
|
+
testID?: string;
|
|
29
|
+
}
|
|
30
|
+
/** A set of quick choices as chips in an equal-width grid, such as order sizes or leverage steps. Single choice, or none; each chip is a button that reads selected, 44dp tall with a 48dp touch target, in the interface face. TargetBlock draws its presets with it. */
|
|
31
|
+
export declare function PresetGroup<T extends string | number = string>({ label, options, value, defaultValue, onValueChange, columns, selectedIntent, disabled, suppressFeedback, style, testID }: PresetGroupProps<T>): React.JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { assertUniqueKeys } from '@bloxwap/hig/contracts';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { useColors, useControllable, useHIG } from './provider.js';
|
|
5
|
+
import { Button } from './button.js';
|
|
6
|
+
import { Text } from './surface.js';
|
|
7
|
+
/**
|
|
8
|
+
* A chip is 44dp tall; 2dp above and below make its 48dp touch target (Material's 48dp target around a smaller visual,
|
|
9
|
+
* as every HIG native control under 48dp does). Chips and rows sit 8 apart, so the slop reaches half the gap sideways
|
|
10
|
+
* (4) and 2 of it vertically: neighbouring targets meet but never overlap, and a chip narrower than 48 (many columns
|
|
11
|
+
* on a narrow screen) still gets the whole column pitch. Android (Fabric) counts a child's hitSlop in its parent's
|
|
12
|
+
* overflow inset, so slop past the row's own frame is reachable there too, unless a clipping ancestor cuts it.
|
|
13
|
+
*/
|
|
14
|
+
const chipSlop = { top: 2, bottom: 2, left: 4, right: 4 };
|
|
15
|
+
/** A set of quick choices as chips in an equal-width grid, such as order sizes or leverage steps. Single choice, or none; each chip is a button that reads selected, 44dp tall with a 48dp touch target, in the interface face. TargetBlock draws its presets with it. */
|
|
16
|
+
export function PresetGroup({ label, options, value, defaultValue = null, onValueChange, columns, selectedIntent = 'primary', disabled, suppressFeedback, style, testID }) {
|
|
17
|
+
assertUniqueKeys(options, option => option.value, 'Choices');
|
|
18
|
+
const { direction } = useHIG(), colors = useColors();
|
|
19
|
+
const [current, set] = useControllable(value, defaultValue, onValueChange, suppressFeedback ? null : 'selection');
|
|
20
|
+
const count = Math.max(1, Math.floor(columns ?? options.length) || 1), rows = [];
|
|
21
|
+
for (let index = 0; index < options.length; index += count)
|
|
22
|
+
rows.push(options.slice(index, index + count));
|
|
23
|
+
// The label is one line in every chip: a label wider than its column shrinks to fit (down to three quarters of its
|
|
24
|
+
// size) instead of wrapping, so `$63,000` never breaks over two lines in a narrow column. Colours are Button's own.
|
|
25
|
+
const chip = (option) => {
|
|
26
|
+
const selected = current !== null && Object.is(current, option.value), blocked = !!disabled || !!option.disabled;
|
|
27
|
+
const color = blocked ? colors.muted : !selected ? colors.text : selectedIntent === 'primary' ? colors.onAction : colors.background;
|
|
28
|
+
return _jsx(Button, { testID: option.testID ?? (testID === undefined ? undefined : `${testID}-${option.value}`), intent: selected ? selectedIntent : 'secondary', disabled: blocked || undefined, accessibilityLabel: option.label, accessibilityState: { selected }, accessibilityHint: label || undefined, hitSlop: chipSlop, suppressFeedback: true, contentMode: 'custom', onPress: () => { if (!blocked && !selected)
|
|
29
|
+
set(option.value); }, style: { flex: 1, alignSelf: 'auto', paddingHorizontal: 8 }, children: _jsx(Text, { testID: option.testID ? `${option.testID}-label` : testID === undefined ? undefined : `${testID}-${option.value}-label`, numberOfLines: 1, adjustsFontSizeToFit: true, minimumFontScale: 0.75, style: { alignSelf: 'stretch', color, fontSize: 16, fontWeight: '600', textAlign: 'center' }, children: option.label }) }, String(option.value));
|
|
30
|
+
};
|
|
31
|
+
// A short row keeps the column width, as the web grid does: empty cells hold the place of the missing chips, also in a single row with more columns than options.
|
|
32
|
+
const row = (items, key, own) => _jsxs(View, { ...own, style: [{ direction, flexDirection: 'row', gap: 8 }, key === undefined ? { alignSelf: 'stretch' } : null, key === undefined ? style : null], children: [items.map(chip), Array.from({ length: items.length > 0 ? count - items.length : 0 }, (_, cell) => _jsx(View, { style: { flex: 1 } }, `cell-${cell}`))] }, key);
|
|
33
|
+
// React Native has no named group: VoiceOver never reads a container that is not an element (RN exposes no
|
|
34
|
+
// `accessibilityContainerType`), and TalkBack reads a plain container's description unreliably. So the group's name
|
|
35
|
+
// reaches each chip as its hint, which both read after the chip ("$25, button, selected, Size"), and the container
|
|
36
|
+
// carries none, so it is never read twice.
|
|
37
|
+
const group = { testID };
|
|
38
|
+
return rows.length > 1 ? _jsx(View, { ...group, style: [{ alignSelf: 'stretch', gap: 8 }, style], children: rows.map((items, index) => row(items, index)) }) : row(rows[0] ?? [], undefined, group);
|
|
39
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ScrollViewProps } from 'react-native';
|
|
3
|
+
import { type PresetOption } from './preset-group.js';
|
|
4
|
+
import { type ScreenHeaderControlProps } from './screen-header.js';
|
|
5
|
+
/** The row that opens the host's own entry of a value no quick choice holds, such as a keypad. */
|
|
6
|
+
export interface PresetPickerCustom {
|
|
7
|
+
/** The row's text: Custom amount. */
|
|
8
|
+
label: string;
|
|
9
|
+
/** Called on a press; the host opens its own entry. */
|
|
10
|
+
onSelect: () => void;
|
|
11
|
+
/** The value the host's entry set, as host text: `$75`. It is drawn on the trailing edge and the row reads as selected. */
|
|
12
|
+
value?: string;
|
|
13
|
+
/** Whether the row reads as selected. Defaults to whether `value` is given. */
|
|
14
|
+
selected?: boolean;
|
|
15
|
+
/** The row's accessible name, in place of its text (and value): Edit custom size, current $75. */
|
|
16
|
+
accessibilityLabel?: string;
|
|
17
|
+
/** The row's test ID, in place of `<testID>-custom`. */
|
|
18
|
+
testID?: string;
|
|
19
|
+
/** Pressable props for the row, such as `{android_disableSound: true}` when the host plays its own sound. HIG keeps its own name, role, state and press. */
|
|
20
|
+
pressProps?: ScreenHeaderControlProps;
|
|
21
|
+
}
|
|
22
|
+
/** Steps through the chips with the screen reader's adjust gesture (swipe up or down on iOS, volume keys on Android). */
|
|
23
|
+
export interface PresetPickerAdjustable {
|
|
24
|
+
/** Name of the increment action: Increase leverage. */
|
|
25
|
+
incrementLabel: string;
|
|
26
|
+
/** Name of the decrement action: Decrease leverage. */
|
|
27
|
+
decrementLabel: string;
|
|
28
|
+
/** The adjustable view's test ID, in place of `<testID>-adjustable`. */
|
|
29
|
+
testID?: string;
|
|
30
|
+
/** The lowest value the control reaches, reported in `accessibilityValue.min` with `max` and `now`: 1 for leverage. */
|
|
31
|
+
min?: number;
|
|
32
|
+
/** The highest value the control reaches, reported in `accessibilityValue.max`: 40 for leverage. */
|
|
33
|
+
max?: number;
|
|
34
|
+
/** The current value, reported in `accessibilityValue.now`: 10 for 10×. Defaults to the selected chip's value when it is a number. */
|
|
35
|
+
now?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface PresetPickerBlockProps<T extends string | number = number> {
|
|
38
|
+
/** Heading of the header. Leave it out for a pane whose host draws its own header: the block then starts at the headline figure. */
|
|
39
|
+
title?: string;
|
|
40
|
+
/** The headline figure, the value being chosen. `null` reads as unknown. */
|
|
41
|
+
value: number | null;
|
|
42
|
+
/** Format of the headline figure, such as `{style:'currency',currency:'USD',maximumFractionDigits:0}`. */
|
|
43
|
+
valueOptions?: Intl.NumberFormatOptions;
|
|
44
|
+
/** Text drawn before the figure. */
|
|
45
|
+
valuePrefix?: string;
|
|
46
|
+
/** Text drawn after the figure, such as `×` for leverage. */
|
|
47
|
+
valueSuffix?: string;
|
|
48
|
+
/** What the figure is read as before its value: Size. */
|
|
49
|
+
valueLabel?: string;
|
|
50
|
+
/** The host's own text for the figure, in place of formatting `value` with `valueOptions`, for a host with its own number table: `$1,250.50`. Drawn and read as given, static unless `animateFormatted`; `value` still decides known or unknown. As `AnimatedNumberReadout` `formattedValue`. */
|
|
51
|
+
formattedValue?: string;
|
|
52
|
+
/** With `formattedValue`, rolls each of its digits in place, counted from the end, as `AnimatedNumberReadout` `animateFormatted`. */
|
|
53
|
+
animateFormatted?: boolean;
|
|
54
|
+
/** The quick choices as chips, in order: `{value, label, disabled?, testID?}`. Labels are host text: `$25`, `Max`, `40×`. A chip without `testID` takes `<testID>-preset-<value>`. */
|
|
55
|
+
presets: readonly PresetOption<T>[];
|
|
56
|
+
/** The chip shown selected; `null` selects none, such as for a custom value. */
|
|
57
|
+
selected: T | null;
|
|
58
|
+
/** Called with the chip taken. A press on the selected chip, or on a dimmed one, does nothing. */
|
|
59
|
+
onPresetChange: (value: T) => void;
|
|
60
|
+
/** Accessible name of the chips, read as each chip's hint: Size. Defaults to `title`. */
|
|
61
|
+
presetsLabel?: string;
|
|
62
|
+
/** Chips per row. Defaults to every chip in one row. */
|
|
63
|
+
columns?: number;
|
|
64
|
+
/** Makes the chips one adjustable control that steps to the next or previous enabled chip, named by `presetsLabel` and valued by the selected chip's label. */
|
|
65
|
+
adjustable?: PresetPickerAdjustable;
|
|
66
|
+
/** The row that opens the host's own entry, drawn above the chips. */
|
|
67
|
+
custom?: PresetPickerCustom;
|
|
68
|
+
/** Fill of the selected chip, the selected custom row and the confirming action: `primary` (the default) or `destructive`. */
|
|
69
|
+
intent?: 'primary' | 'destructive';
|
|
70
|
+
/** Drawn as given between the chips and the actions, such as a muted note. */
|
|
71
|
+
children?: React.ReactNode;
|
|
72
|
+
/** Called on the confirming action. */
|
|
73
|
+
onSubmit: () => void;
|
|
74
|
+
/** Text of the confirming action: Set Size. */
|
|
75
|
+
submitLabel: string;
|
|
76
|
+
submitDisabled?: boolean;
|
|
77
|
+
/** The confirming action shows a spinner and ignores presses. */
|
|
78
|
+
busy?: boolean;
|
|
79
|
+
/** Shows Cancel on the leading side of the confirming action, the two sharing the row equally. */
|
|
80
|
+
onCancel?: () => void;
|
|
81
|
+
/** Text of Cancel. Defaults to the built-in "Cancel". */
|
|
82
|
+
cancelLabel?: string;
|
|
83
|
+
/** Keeps the provider's feedback off the chips and both actions, for a host that plays its own cue. */
|
|
84
|
+
suppressFeedback?: boolean;
|
|
85
|
+
/** Shows Back on the leading edge of the header (needs `title`). */
|
|
86
|
+
onBack?: () => void;
|
|
87
|
+
/** Pressable props for Back, such as `{android_disableSound: true}`. */
|
|
88
|
+
backProps?: ScreenHeaderControlProps;
|
|
89
|
+
/** A control on the trailing edge of the header, usually an IconButton. */
|
|
90
|
+
headerAction?: React.ReactNode;
|
|
91
|
+
/** `nativeID` of the title, so a sheet can name itself with `accessibilityLabelledBy` (Android). */
|
|
92
|
+
headingId?: string;
|
|
93
|
+
/** Keeps the header pinned while the rest scrolls: the block becomes its own scroll view with the header as its sticky first child. Needs `title`; place it in a bounded container. */
|
|
94
|
+
stickyHeader?: boolean;
|
|
95
|
+
/** With `stickyHeader`: the header's fill once content is under it. Defaults to the background role; in a sheet pass the sheet's fill. */
|
|
96
|
+
stickyHeaderBackground?: string;
|
|
97
|
+
/** The scroll view used with `stickyHeader`, such as a sheet library's own. */
|
|
98
|
+
scrollComponent?: React.ComponentType<ScrollViewProps>;
|
|
99
|
+
/** Prefix of the test IDs: `<testID>-header`, `-back`, `-title`, `-headline`, `-custom`, `-custom-value`, `-presets`, `-preset-<value>`, `-adjustable`, `-actions`, `-cancel` and `-confirm`. Defaults to `preset-picker`. */
|
|
100
|
+
testID?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Choose one value from quick choices as a screen: an optional header, the value as the headline figure, an optional row that opens the
|
|
104
|
+
* host's own entry, the choices as chips, then Cancel and the confirming action. Draws a trade sheet's Size and Leverage panes. It reuses
|
|
105
|
+
* TargetBlock's parts (the headline, the Custom row, PresetGroup and the actions row) without its price card and unit control.
|
|
106
|
+
*/
|
|
107
|
+
export declare function PresetPickerBlock<T extends string | number = number>({ title, value, valueOptions, valuePrefix, valueSuffix, valueLabel, formattedValue, animateFormatted, presets, selected, onPresetChange, presetsLabel, columns, adjustable, custom, intent, children, onSubmit, submitLabel, submitDisabled, busy, onCancel, cancelLabel, suppressFeedback, onBack, backProps, headerAction, headingId, stickyHeader, stickyHeaderBackground, scrollComponent, testID }: PresetPickerBlockProps<T>): React.JSX.Element;
|