@bloxwap/hig 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chart/README.md +1 -1
- package/contracts/README.md +1 -1
- package/contracts/dist/index.d.ts +16 -0
- package/contracts/dist/index.js +22 -0
- package/contracts/dist/messages.d.ts +6 -0
- package/contracts/dist/messages.js +3 -1
- package/feedback/README.md +1 -1
- package/native/README.md +1 -1
- package/native/dist/account-block.d.ts +53 -7
- package/native/dist/account-block.js +42 -9
- package/native/dist/animated-number-model.d.ts +7 -1
- package/native/dist/animated-number-model.js +50 -1
- package/native/dist/animated-number.d.ts +3 -1
- package/native/dist/animated-number.js +8 -5
- package/native/dist/asset-balance-row.d.ts +17 -1
- package/native/dist/asset-balance-row.js +13 -8
- package/native/dist/bar-mark.d.ts +14 -2
- package/native/dist/bar-mark.js +19 -5
- package/native/dist/bar-pnl.js +5 -4
- package/native/dist/blocks.d.ts +8 -14
- package/native/dist/blocks.js +5 -6
- package/native/dist/button.js +3 -1
- package/native/dist/data.d.ts +1 -1
- package/native/dist/data.js +6 -4
- package/native/dist/field.d.ts +14 -4
- package/native/dist/field.js +33 -7
- package/native/dist/figure.d.ts +23 -0
- package/native/dist/figure.js +10 -0
- package/native/dist/language-block.d.ts +5 -1
- package/native/dist/language-block.js +3 -3
- package/native/dist/list-group.d.ts +42 -8
- package/native/dist/list-group.js +71 -13
- package/native/dist/manage-position-block.d.ts +28 -2
- package/native/dist/manage-position-block.js +36 -11
- package/native/dist/market-row.d.ts +46 -0
- package/native/dist/market-row.js +30 -0
- package/native/dist/notifications-block.d.ts +30 -2
- package/native/dist/notifications-block.js +16 -8
- package/native/dist/pickers.d.ts +24 -2
- package/native/dist/pickers.js +16 -8
- package/native/dist/position-block.d.ts +66 -10
- package/native/dist/position-block.js +45 -11
- package/native/dist/profile-block.d.ts +29 -5
- package/native/dist/profile-block.js +25 -5
- package/native/dist/provider.d.ts +9 -3
- package/native/dist/provider.js +7 -3
- package/native/dist/radio-group.d.ts +9 -3
- package/native/dist/radio-group.js +4 -5
- package/native/dist/recipes.d.ts +6 -0
- package/native/dist/recipes.js +6 -0
- package/native/dist/reward-block.d.ts +45 -6
- package/native/dist/reward-block.js +30 -12
- package/native/dist/screen-header.d.ts +49 -0
- package/native/dist/screen-header.js +29 -0
- package/native/dist/selection.d.ts +2 -2
- package/native/dist/setting-header.d.ts +2 -8
- package/native/dist/setting-header.js +2 -11
- package/native/dist/setting-switch.d.ts +14 -1
- package/native/dist/setting-switch.js +5 -2
- package/native/dist/signals-block.d.ts +26 -2
- package/native/dist/signals-block.js +14 -4
- package/native/dist/sound-haptics-block.d.ts +29 -2
- package/native/dist/sound-haptics-block.js +18 -7
- package/native/dist/status.d.ts +6 -5
- package/native/dist/status.js +5 -5
- package/native/dist/sticky-header.d.ts +28 -0
- package/native/dist/sticky-header.js +21 -0
- package/native/dist/surface.d.ts +3 -1
- package/native/dist/surface.js +2 -1
- package/native/dist/swap-panel-block.d.ts +2 -1
- package/native/dist/swap-panel-block.js +9 -6
- package/native/dist/swap-parts.d.ts +5 -3
- package/native/dist/swap-parts.js +2 -2
- package/native/dist/swap-shared.d.ts +6 -0
- package/native/dist/swap-views.js +5 -3
- package/native/dist/switch-row.d.ts +3 -2
- package/native/dist/switch-row.js +5 -3
- package/native/dist/switch.d.ts +4 -2
- package/native/dist/switch.js +3 -3
- package/native/dist/target-block.d.ts +33 -6
- package/native/dist/target-block.js +19 -6
- package/native/dist/token-action-block.d.ts +17 -9
- package/native/dist/token-action-block.js +14 -6
- package/native/dist/trade-history-detail-block.d.ts +26 -1
- package/native/dist/trade-history-detail-block.js +17 -9
- package/native/dist/trade-history-list-block.d.ts +71 -5
- package/native/dist/trade-history-list-block.js +50 -15
- package/native/dist/wallet-address-core.d.ts +25 -0
- package/native/dist/wallet-address-core.js +31 -0
- package/native/dist/wallet-address.d.ts +6 -10
- package/native/dist/wallet-address.js +16 -20
- package/native-fonts/README.md +1 -1
- package/og-fonts/README.md +1 -1
- package/package.json +21 -1
- package/react/README.md +1 -1
- package/react/dist/animated-number-model.d.ts +6 -0
- package/react/dist/animated-number-model.js +33 -0
- package/react/dist/animated-number.d.ts +5 -1
- package/react/dist/animated-number.js +12 -8
- package/react/dist/asset-balance-row.d.ts +17 -1
- package/react/dist/asset-balance-row.js +11 -3
- package/react/dist/bar-mark.d.ts +5 -2
- package/react/dist/bar-mark.js +5 -3
- package/react/dist/blocks/account-block.d.ts +53 -7
- package/react/dist/blocks/account-block.js +45 -10
- package/react/dist/blocks/language-block.d.ts +5 -1
- package/react/dist/blocks/language-block.js +6 -5
- package/react/dist/blocks/manage-position-block.d.ts +28 -2
- package/react/dist/blocks/manage-position-block.js +23 -4
- package/react/dist/blocks/market-row.d.ts +20 -9
- package/react/dist/blocks/market-row.js +12 -4
- package/react/dist/blocks/notifications-block.d.ts +25 -2
- package/react/dist/blocks/notifications-block.js +11 -2
- package/react/dist/blocks/pickers.d.ts +21 -1
- package/react/dist/blocks/pickers.js +30 -10
- package/react/dist/blocks/position-block.d.ts +34 -11
- package/react/dist/blocks/position-block.js +16 -5
- package/react/dist/blocks/profile-block.d.ts +29 -6
- package/react/dist/blocks/profile-block.js +31 -5
- package/react/dist/blocks/reward-block.d.ts +53 -14
- package/react/dist/blocks/reward-block.js +20 -10
- package/react/dist/blocks/screen-header.d.ts +26 -2
- package/react/dist/blocks/screen-header.js +13 -5
- package/react/dist/blocks/setting-switch.d.ts +14 -1
- package/react/dist/blocks/setting-switch.js +8 -4
- package/react/dist/blocks/signals-block.d.ts +21 -2
- package/react/dist/blocks/signals-block.js +5 -5
- package/react/dist/blocks/sound-haptics-block.d.ts +25 -3
- package/react/dist/blocks/sound-haptics-block.js +11 -7
- package/react/dist/blocks/sticky-header.d.ts +9 -0
- package/react/dist/blocks/sticky-header.js +43 -0
- package/react/dist/blocks/swap/amount-card.js +2 -1
- package/react/dist/blocks/swap/settings.js +2 -2
- package/react/dist/blocks/swap/shared.d.ts +7 -1
- package/react/dist/blocks/swap/shared.js +6 -4
- package/react/dist/blocks/swap-panel-block.d.ts +2 -0
- package/react/dist/blocks/swap-panel-block.js +6 -6
- package/react/dist/blocks/target-block.d.ts +28 -6
- package/react/dist/blocks/target-block.js +17 -9
- package/react/dist/blocks/token-action-block.d.ts +17 -8
- package/react/dist/blocks/token-action-block.js +9 -6
- package/react/dist/blocks/trade-history-detail-block.d.ts +21 -1
- package/react/dist/blocks/trade-history-detail-block.js +5 -4
- package/react/dist/blocks/trade-history-list-block.d.ts +29 -5
- package/react/dist/blocks/trade-history-list-block.js +15 -8
- package/react/dist/blocks.d.ts +8 -8
- package/react/dist/blocks.js +2 -2
- package/react/dist/button.js +6 -4
- package/react/dist/data.js +3 -3
- package/react/dist/field.d.ts +14 -4
- package/react/dist/field.js +19 -6
- package/react/dist/figure.d.ts +23 -0
- package/react/dist/figure.js +12 -0
- package/react/dist/list-group.d.ts +41 -8
- package/react/dist/list-group.js +44 -12
- package/react/dist/provider.d.ts +40 -3
- package/react/dist/provider.js +63 -6
- package/react/dist/selection.d.ts +8 -2
- package/react/dist/selection.js +11 -6
- package/react/dist/styles.css +164 -9
- package/react/dist/surface.d.ts +5 -1
- package/react/dist/surface.js +1 -1
- package/react/dist/wallet-address-core.d.ts +23 -0
- package/react/dist/wallet-address-core.js +24 -0
- package/react/dist/wallet-address.d.ts +6 -12
- package/react/dist/wallet-address.js +5 -16
- package/tokens/README.md +1 -1
|
@@ -1,21 +1,55 @@
|
|
|
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, useFills, useHIG, useMessages } from './provider.js';
|
|
3
|
+
import { useColors, useFills, useHIG, useMessages, useNumberLocale, usePresentNumber } from './provider.js';
|
|
4
4
|
import { Text } from './surface.js';
|
|
5
|
-
import {
|
|
6
|
-
import { ChevronIcon, CloseIcon } from './icons.js';
|
|
5
|
+
import { Button } from './button.js';
|
|
7
6
|
import { SwitchRow } from './switch-row.js';
|
|
8
7
|
import { ListGroup, ListRow } from './list-group.js';
|
|
9
8
|
import { AnimatedNumberReadout } from './animated-number.js';
|
|
10
|
-
import {
|
|
9
|
+
import { HeaderClose, ScreenHeader } from './screen-header.js';
|
|
10
|
+
import { StickyHeaderLayout, stickyHeaderFill } from './sticky-header.js';
|
|
11
|
+
import { figureProps, figureReading } from './figure.js';
|
|
11
12
|
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
13
|
+
function HeaderRow({ title, onClose, onBack, headerAction, headingId, backProps, closeProps }) {
|
|
14
|
+
const t = useMessages();
|
|
15
|
+
return _jsx(ScreenHeader, { testID: 'position', title: title, onBack: onBack, backProps: backProps, headingId: headingId, action: headerAction ?? (onClose ? _jsx(HeaderClose, { testID: 'position-close', label: t.close, onClose: onClose, closeProps: closeProps }) : null) });
|
|
16
|
+
}
|
|
17
|
+
/** 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. */
|
|
18
|
+
export function PositionBlockHeader({ style, testID, scrolled, stickyHeaderBackground, ...props }) {
|
|
19
|
+
const colors = useColors();
|
|
20
|
+
return _jsx(View, { testID: testID, style: [{ paddingTop: 16, paddingHorizontal: 16 }, scrolled === undefined ? undefined : stickyHeaderFill(scrolled, stickyHeaderBackground ?? colors.background), style], children: _jsx(HeaderRow, { ...props }) });
|
|
21
|
+
}
|
|
22
|
+
function Track({ checked, testID }) {
|
|
23
|
+
const colors = useColors(), fills = useFills();
|
|
24
|
+
return _jsx(View, { testID: testID, style: { width: 40, height: 24, borderRadius: 12, padding: 3, backgroundColor: checked ? colors.action : fills.raised, alignItems: checked ? 'flex-end' : 'flex-start' }, children: _jsx(View, { style: { width: 18, height: 18, borderRadius: 9, backgroundColor: checked ? colors.onAction : colors.text } }) });
|
|
25
|
+
}
|
|
12
26
|
/** The position being opened or edited as a screen: a summary of what it costs and where it ends, an optional paper trading switch, and its settings as grouped rows that open the host's own views. */
|
|
13
|
-
export function PositionBlock({ title, details, note, paperTrade, groups, onClose, onBack, headerAction, testID }) {
|
|
14
|
-
const colors = useColors(), fills = useFills(),
|
|
27
|
+
export function PositionBlock({ title, details, note, paperTrade, groups, onClose, onBack, headerAction, headingId, header = true, stickyHeader, stickyHeaderBackground, scrollComponent, backProps, closeProps, testID }) {
|
|
28
|
+
const colors = useColors(), fills = useFills(), { direction } = useHIG(), locale = useNumberLocale(), present = usePresentNumber();
|
|
15
29
|
const figure = { fontSize: 16, lineHeight: 24, fontWeight: '500' };
|
|
16
30
|
const shown = groups.filter(group => group.length > 0);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
const read = (live) => figureReading(live, locale, present(live.options));
|
|
32
|
+
const flagRow = paperTrade ? _jsx(SwitchRow, { testID: 'position-paper-trade', label: paperTrade.label, checked: paperTrade.checked, disabled: paperTrade.disabled, onCheckedChange: paperTrade.onCheckedChange, style: { minHeight: 56, paddingVertical: 8, paddingHorizontal: 20, borderRadius: 20, backgroundColor: fills.well, opacity: paperTrade.disabled ? 0.5 : 1 }, children: _jsxs(View, { style: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [_jsx(Text, { style: { flex: 1, flexShrink: 1, minWidth: 0, fontSize: 16, lineHeight: 24, color: colors.text }, children: paperTrade.label }), _jsx(Track, { checked: paperTrade.checked, testID: 'position-paper-trade-track' })] }) }) : null;
|
|
33
|
+
const action = paperTrade?.action;
|
|
34
|
+
const row = (item) => {
|
|
35
|
+
const live = item.value == null || typeof item.value === 'string' ? null : item.value, reading = live ? read(live) : item.value;
|
|
36
|
+
if (item.onCheckedChange)
|
|
37
|
+
return _jsx(SwitchRow, { testID: `position-row-${item.id}`, label: item.label, accessibilityHint: reading, checked: !!item.checked, disabled: item.disabled, onCheckedChange: item.onCheckedChange, style: { minHeight: 56, paddingVertical: 8, paddingHorizontal: 20, backgroundColor: fills.well, opacity: item.disabled ? 0.5 : 1 }, children: _jsxs(View, { style: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [_jsx(Text, { style: { flex: 1, flexShrink: 1, minWidth: 0, fontSize: 16, lineHeight: 24, color: colors.text }, children: item.label }), live ? _jsx(AnimatedNumberReadout, { ...figureProps(live), tone: 'muted', style: { fontSize: 16, lineHeight: 24 } }) : reading ? _jsx(Text, { numberOfLines: 1, style: { flexShrink: 1, maxWidth: '50%', fontSize: 16, lineHeight: 24, color: colors.muted, textAlign: 'right' }, children: reading }) : null, _jsx(Track, { checked: !!item.checked, testID: `position-row-${item.id}-track` })] }) }, item.id);
|
|
38
|
+
return _jsx(ListRow, { testID: `position-row-${item.id}`, label: item.label, value: live ? _jsx(AnimatedNumberReadout, { ...figureProps(live), tone: 'muted', testID: `position-row-${item.id}-value`, style: { fontSize: 16, lineHeight: 24 } }) : item.value, valueLabel: live ? reading : undefined, onSelect: item.onSelect, disabled: item.disabled }, item.id);
|
|
39
|
+
};
|
|
40
|
+
const headerRow = _jsx(HeaderRow, { title: title, onClose: onClose, onBack: onBack, headerAction: headerAction, headingId: headingId, backProps: backProps, closeProps: closeProps });
|
|
41
|
+
const content = _jsxs(_Fragment, { children: [details.length > 0 ? _jsx(View, { testID: 'position-details', style: { gap: 12, marginTop: 16, paddingHorizontal: 20 }, children: details.map((detail, index) => {
|
|
42
|
+
const key = detail.id ?? index, live = typeof detail.value === 'string' ? null : detail.value, reading = live ? read(live) : detail.value;
|
|
43
|
+
const spoken = `${detail.label}, ${reading}${detail.struck ? `, ${detail.struck}` : ''}`;
|
|
44
|
+
const value = live ? _jsx(AnimatedNumberReadout, { ...figureProps(live), tone: detail.tone ?? 'text', style: figure }) : _jsx(Text, { style: { ...figure, color: detail.tone ? colors[detail.tone] : colors.text, textAlign: 'right' }, children: reading });
|
|
45
|
+
// The line is drawn over the figure, so it crosses animated digits as well as text.
|
|
46
|
+
const drawn = detail.struck ? _jsxs(View, { testID: `position-detail-${key}-struck`, style: { position: 'relative' }, children: [value, _jsx(View, { pointerEvents: 'none', style: { position: 'absolute', start: 0, end: 0, top: '50%', height: 1, backgroundColor: detail.tone ? colors[detail.tone] : colors.text } })] }) : value;
|
|
47
|
+
const label = _jsx(Text, { ...hidden, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, color: colors.muted }, children: detail.label });
|
|
48
|
+
if (detail.labelAccessory != null)
|
|
49
|
+
return _jsxs(View, { testID: `position-detail-${key}`, style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12 }, children: [_jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', gap: 6, flexShrink: 1 }, children: [_jsx(Text, { testID: `position-detail-${key}-label`, accessible: true, accessibilityLabel: spoken, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, color: colors.muted }, children: detail.label }), detail.labelAccessory] }), _jsx(View, { ...hidden, style: { flexShrink: 1 }, children: drawn })] }, key);
|
|
50
|
+
return _jsxs(View, { testID: `position-detail-${key}`, accessible: true, accessibilityLabel: spoken, style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12 }, children: [label, _jsx(View, { ...hidden, style: { flexShrink: 1 }, children: drawn })] }, key);
|
|
51
|
+
}) }) : null, note ? _jsx(Text, { testID: 'position-note', style: { color: colors.muted, fontSize: 13, lineHeight: 20, marginTop: 8, paddingHorizontal: 20 }, children: note }) : null, paperTrade || shown.length > 0 ? _jsxs(View, { testID: 'position-groups', style: { gap: 24, marginTop: 16 }, children: [action ? _jsxs(View, { testID: 'position-paper-trade-card', style: { borderRadius: 20, overflow: 'hidden', backgroundColor: fills.well }, children: [flagRow, _jsx(View, { style: { paddingHorizontal: 20, paddingBottom: 16 }, children: _jsx(Button, { testID: 'position-paper-trade-action', fullWidth: true, intent: action.intent ?? 'primary', busy: action.busy, disabled: action.disabled, onPress: action.onSelect, children: action.label }) })] }) : flagRow, shown.map((group, index) => _jsx(ListGroup, { testID: `position-group-${index}`, children: group.map(row) }, index))] }) : null] });
|
|
52
|
+
if (header && stickyHeader)
|
|
53
|
+
return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: 'position-sticky-header', header: headerRow, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: content });
|
|
54
|
+
return _jsxs(View, { testID: testID, style: header ? { padding: 16 } : { padding: 16, paddingTop: 0 }, children: [header ? headerRow : null, content] });
|
|
21
55
|
}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type Figure } from './figure.js';
|
|
2
3
|
import type { AssetArtwork } from './asset-balance-row.js';
|
|
3
4
|
export type { AssetArtwork } from './asset-balance-row.js';
|
|
5
|
+
/** A row value that can change while the profile is shown, such as a balance: formatted with `options` between `prefix` and `suffix`, and updated place by place. `null` reads as unknown. */
|
|
6
|
+
export type ProfileFigure = Figure;
|
|
4
7
|
/** One row of a profile section. The host supplies every label and value. */
|
|
5
8
|
export interface ProfileRow {
|
|
6
9
|
id: string;
|
|
7
10
|
label: string;
|
|
8
11
|
leading?: React.ReactNode;
|
|
9
|
-
|
|
12
|
+
/** Short text on the trailing edge, or a live figure that updates place by place. */
|
|
13
|
+
value?: React.ReactNode | ProfileFigure;
|
|
14
|
+
/** Colours the value. Without it the value keeps the row's muted value style. */
|
|
15
|
+
tone?: 'positive' | 'warning' | 'negative' | 'muted';
|
|
10
16
|
trailing?: React.ReactNode;
|
|
11
17
|
onSelect?: () => void;
|
|
12
18
|
disabled?: boolean;
|
|
13
|
-
/** With `onCheckedChange`, the row is a switch: the track trails and the label names it. */
|
|
19
|
+
/** With `onCheckedChange`, the row is a switch: the whole row is the target, the track trails and the label names it. */
|
|
14
20
|
checked?: boolean;
|
|
15
21
|
onCheckedChange?: (checked: boolean) => void;
|
|
16
22
|
}
|
|
@@ -25,18 +31,36 @@ export interface ProfileStatus {
|
|
|
25
31
|
label: string;
|
|
26
32
|
tone?: 'positive' | 'warning' | 'negative' | 'info';
|
|
27
33
|
}
|
|
34
|
+
/** The primary action under the name, such as Log in for a signed-out viewer. The host writes the label. */
|
|
35
|
+
export interface ProfileAction {
|
|
36
|
+
label: string;
|
|
37
|
+
onSelect: () => void;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/** Defaults to `primary`. */
|
|
40
|
+
intent?: 'primary' | 'secondary';
|
|
41
|
+
}
|
|
28
42
|
export interface ProfileBlockProps {
|
|
29
|
-
/** The name under the avatar: a display name or a shortened address. */
|
|
30
|
-
name
|
|
43
|
+
/** The name under the avatar: a display name or a shortened address. It may be left out when `action` is set, for a signed-out viewer. */
|
|
44
|
+
name?: string;
|
|
45
|
+
/** Host content beside the name, such as a badge. It stays in the accessibility tree, so give an interactive badge its own label. */
|
|
46
|
+
nameAccessory?: React.ReactNode;
|
|
31
47
|
/** Colours the avatar when there is no artwork. */
|
|
32
48
|
address?: string;
|
|
33
49
|
avatar?: AssetArtwork;
|
|
50
|
+
/** Makes the avatar a button, for example to choose a picture. `avatarLabel` names it. */
|
|
51
|
+
onAvatarPress?: () => void;
|
|
52
|
+
/** The accessible name of the avatar button, such as Change profile picture. Defaults to `name`, then the built-in “Change profile picture”. */
|
|
53
|
+
avatarLabel?: string;
|
|
34
54
|
status?: ProfileStatus;
|
|
35
55
|
onEditName?: () => void;
|
|
36
56
|
onShowAddress?: () => void;
|
|
37
57
|
onClose?: () => void;
|
|
58
|
+
/** A full-width button under the name, such as Log in. */
|
|
59
|
+
action?: ProfileAction;
|
|
38
60
|
sections: readonly ProfileSection[];
|
|
61
|
+
/** Host content under the sections on the block's inset, such as legal links. */
|
|
62
|
+
footer?: React.ReactNode;
|
|
39
63
|
testID?: string;
|
|
40
64
|
}
|
|
41
65
|
/** A person's profile as one screen: the address and close controls, the avatar with its status, the name, then the host's sections of rows. */
|
|
42
|
-
export declare function ProfileBlock({ name, address, avatar, status, onEditName, onShowAddress, onClose, sections, testID }: ProfileBlockProps): React.JSX.Element;
|
|
66
|
+
export declare function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, testID }: ProfileBlockProps): React.JSX.Element;
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import { Image, Pressable, View } from 'react-native';
|
|
3
|
-
import { useColors, useFills, useHIG, useMessages } from './provider.js';
|
|
4
|
+
import { useColors, useFills, useHIG, useMessages, useNumberLocale, usePresentNumber } from './provider.js';
|
|
4
5
|
import { Text } from './surface.js';
|
|
6
|
+
import { Button } from './button.js';
|
|
5
7
|
import { CloseIcon, EditIcon, QrIcon } from './icons.js';
|
|
6
8
|
import { ListGroup, ListRow } from './list-group.js';
|
|
7
9
|
import { SwitchRow } from './switch-row.js';
|
|
10
|
+
import { AnimatedNumberReadout } from './animated-number.js';
|
|
11
|
+
import { figureProps, figureReading } from './figure.js';
|
|
8
12
|
import { addressColor } from './swap-shared.js';
|
|
9
13
|
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
14
|
+
/** A 44dp control keeps a 48dp touch target on every side. */
|
|
15
|
+
const targetSlop = { top: 2, bottom: 2, left: 2, right: 2 };
|
|
16
|
+
/** True for a `ProfileFigure`: a plain object with a `value`, not an element, array or other node. */
|
|
17
|
+
const isProfileFigure = (value) => value != null && typeof value === 'object' && !React.isValidElement(value) && !Array.isArray(value) && !(Symbol.iterator in value) && 'value' in value;
|
|
10
18
|
/** A round 44 control with no fill of its own, like the other block headers; it takes the well fill while pressed. */
|
|
11
19
|
function RoundButton({ label, testID, onPress, children }) {
|
|
12
20
|
const fills = useFills();
|
|
13
|
-
return _jsx(Pressable, { testID: testID, accessibilityRole: 'button', accessibilityLabel: label, onPress: onPress, hitSlop:
|
|
21
|
+
return _jsx(Pressable, { testID: testID, accessibilityRole: 'button', accessibilityLabel: label, onPress: onPress, hitSlop: targetSlop, style: ({ pressed }) => ({ width: 44, height: 44, borderRadius: 22, alignItems: 'center', justifyContent: 'center', backgroundColor: pressed ? fills.well : 'transparent' }), children: children });
|
|
14
22
|
}
|
|
15
23
|
/** A list row that is one switch: the same anatomy as ListRow, with the track on the trailing edge, level with the first line of the label. */
|
|
16
24
|
function ProfileSwitchRow({ row }) {
|
|
@@ -19,10 +27,22 @@ function ProfileSwitchRow({ row }) {
|
|
|
19
27
|
const first = { minHeight: 40, justifyContent: 'center' };
|
|
20
28
|
return _jsx(SwitchRow, { testID: `profile-row-${row.id}`, label: row.label, checked: on, disabled: row.disabled, onCheckedChange: row.onCheckedChange, style: { minHeight: 56, paddingVertical: 8, paddingHorizontal: 20, backgroundColor: fills.well, opacity: row.disabled ? 0.5 : 1 }, children: _jsxs(View, { style: { flex: 1, flexDirection: 'row', alignItems: 'flex-start', gap: 12 }, children: [row.leading == null ? null : _jsx(View, { style: first, children: row.leading }), _jsx(Text, { style: { flex: 1, flexShrink: 1, minWidth: 0, paddingVertical: 8, fontSize: 16, lineHeight: 24, color: colors.text }, children: row.label }), _jsx(View, { style: first, children: _jsx(View, { testID: `profile-row-${row.id}-track`, style: { width: 40, height: 24, borderRadius: 12, padding: 3, backgroundColor: on ? colors.action : fills.raised, alignItems: on ? 'flex-end' : 'flex-start' }, children: _jsx(View, { style: { width: 18, height: 18, borderRadius: 9, backgroundColor: on ? colors.onAction : colors.text } }) }) })] }) });
|
|
21
29
|
}
|
|
30
|
+
/** A row that opens something or shows a value. A live figure or a toned value is drawn here and read through `valueLabel`. */
|
|
31
|
+
function ProfileListRow({ row }) {
|
|
32
|
+
const locale = useNumberLocale(), present = usePresentNumber();
|
|
33
|
+
const { value, tone } = row, testID = `profile-row-${row.id}`;
|
|
34
|
+
const style = { fontSize: 16, lineHeight: 24, textAlign: 'right' };
|
|
35
|
+
if (isProfileFigure(value)) {
|
|
36
|
+
const reading = figureReading(value, locale, present(value.options));
|
|
37
|
+
return _jsx(ListRow, { testID: testID, label: row.label, leading: row.leading, valueLabel: reading, value: _jsx(AnimatedNumberReadout, { ...figureProps(value), tone: tone ?? 'muted', testID: `${testID}-value`, style: style }), trailing: row.trailing, onSelect: row.onSelect, disabled: row.disabled });
|
|
38
|
+
}
|
|
39
|
+
return _jsx(ListRow, { testID: testID, label: row.label, leading: row.leading, value: value, valueTone: tone, trailing: row.trailing, onSelect: row.onSelect, disabled: row.disabled });
|
|
40
|
+
}
|
|
22
41
|
/** A person's profile as one screen: the address and close controls, the avatar with its status, the name, then the host's sections of rows. */
|
|
23
|
-
export function ProfileBlock({ name, address, avatar, status, onEditName, onShowAddress, onClose, sections, testID }) {
|
|
42
|
+
export function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, testID }) {
|
|
24
43
|
const colors = useColors(), fills = useFills(), t = useMessages(), { direction } = useHIG();
|
|
25
|
-
const art = typeof avatar === 'string' ? _jsx(Image, { source: { uri: avatar }, style: { width: 144, height: 144 } }) : avatar ?? (address ? null : _jsx(Text, { style: { fontSize: 40, lineHeight: 48, fontWeight: '600', color: colors.muted }, children: name
|
|
44
|
+
const art = typeof avatar === 'string' ? _jsx(Image, { source: { uri: avatar }, style: { width: 144, height: 144 } }) : avatar ?? (address ? null : _jsx(Text, { style: { fontSize: 40, lineHeight: 48, fontWeight: '600', color: colors.muted }, children: name?.slice(0, 2) }));
|
|
26
45
|
const shown = sections.filter(section => section.rows.length > 0);
|
|
27
|
-
|
|
46
|
+
const disc = _jsx(View, { ...hidden, testID: 'profile-avatar', style: { width: 144, height: 144, borderRadius: 72, overflow: 'hidden', alignItems: 'center', justifyContent: 'center', backgroundColor: avatar == null && address ? addressColor(address) : fills.well }, children: art });
|
|
47
|
+
return _jsxs(View, { testID: testID, style: { direction, padding: 16 }, children: [_jsxs(View, { testID: 'profile-bar', style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', minHeight: 44 }, children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onShowAddress ? _jsx(RoundButton, { label: t.showAddress, testID: 'profile-address', onPress: onShowAddress, children: _jsx(QrIcon, { color: colors.text }) }) : null }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: onClose ? _jsx(RoundButton, { label: t.close, testID: 'profile-close', onPress: onClose, children: _jsx(CloseIcon, { color: colors.text }) }) : null })] }), _jsxs(View, { style: { alignSelf: 'center', width: 144, height: 144, marginTop: 8 }, children: [onAvatarPress ? _jsx(Pressable, { testID: 'profile-avatar-button', accessibilityRole: 'button', accessibilityLabel: avatarLabel ?? name ?? t.changeProfilePicture, onPress: onAvatarPress, style: ({ pressed }) => ({ borderRadius: 72, opacity: pressed ? 0.85 : 1 }), children: disc }) : disc, status ? _jsx(View, { testID: 'profile-status', accessible: true, accessibilityLabel: status.label, style: { position: 'absolute', top: 10, end: 10, width: 20, height: 20, borderRadius: 10, borderWidth: 3, borderColor: colors.background, backgroundColor: colors[status.tone ?? 'warning'] } }) : null] }), name != null ? _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 4, marginTop: 16 }, children: [_jsx(Text, { testID: 'profile-name', accessibilityRole: 'header', numberOfLines: 1, style: { flexShrink: 1, fontSize: 28, lineHeight: 34, fontWeight: '700', color: colors.text }, children: name }), nameAccessory != null ? _jsx(View, { testID: 'profile-name-accessory', style: { flexShrink: 0 }, children: nameAccessory }) : null, onEditName ? _jsx(Pressable, { testID: 'profile-edit', accessibilityRole: 'button', accessibilityLabel: t.editName, onPress: onEditName, hitSlop: targetSlop, style: ({ pressed }) => ({ width: 44, height: 44, alignItems: 'center', justifyContent: 'center', opacity: pressed ? 0.6 : 1 }), children: _jsx(EditIcon, { color: colors.muted }) }) : null] }) : null, action ? _jsx(View, { testID: 'profile-action-row', style: { marginTop: 16 }, children: _jsx(Button, { testID: 'profile-action', fullWidth: true, intent: action.intent ?? 'primary', disabled: action.disabled, onPress: action.onSelect, children: action.label }) }) : null, shown.length > 0 ? _jsx(View, { testID: 'profile-sections', style: { gap: 24, marginTop: 24 }, children: shown.map(section => _jsx(ListGroup, { testID: `profile-section-${section.id}`, title: section.title, children: section.rows.map(row => row.onCheckedChange ? _jsx(ProfileSwitchRow, { row: row }, row.id) : _jsx(ProfileListRow, { row: row }, row.id)) }, section.id)) }) : null, footer != null ? _jsx(View, { testID: 'profile-footer', style: { marginTop: 24 }, children: footer }) : null] });
|
|
28
48
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { FeedbackSink, FeedbackIntent } from '@bloxwap/hig/contracts/feedback';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { nativeSrgb } from '@bloxwap/hig/tokens';
|
|
4
|
-
import { type Environment } from '@bloxwap/hig/contracts';
|
|
4
|
+
import { type Environment, type NumberFormatPresentation } from '@bloxwap/hig/contracts';
|
|
5
|
+
export type { NumberFormatPresentation } from '@bloxwap/hig/contracts';
|
|
5
6
|
import { type HIGMessages } from '@bloxwap/hig/contracts/messages';
|
|
6
7
|
export type { HIGMessages } from '@bloxwap/hig/contracts/messages';
|
|
7
8
|
/** Direction of a host-supplied locale (for example expo-localization's `getLocales()[0]`) for `HIGProvider direction`; see #86. */
|
|
@@ -34,7 +35,8 @@ export interface HIGContext extends Environment {
|
|
|
34
35
|
monoFontFamily?: string; /** Default Dynamic Type / font-scale cap for HIG Text; a Text prop overrides it. Leave unset for prose. */
|
|
35
36
|
maxFontSizeMultiplier?: number; /** Per-script letter spacing in em for Korean and Chinese companion faces; overrides `scriptLetterSpacing`. */
|
|
36
37
|
letterSpacingByScript?: Readonly<Partial<Record<'ko' | 'zh', number>>>; /** Colour space HIG paints in; defaults to `srgb` and is inherited by nested providers. Read the resolved table with `useColors()`. */
|
|
37
|
-
colorSpace: HIGColorSpace; /**
|
|
38
|
+
colorSpace: HIGColorSpace; /** Money presentation merged under every currency format HIG draws: the blocks, BarMark, BarPnl, AssetBalanceRow, the swap pieces and the number readouts. Options a format sets itself win. Nested providers inherit it. */
|
|
39
|
+
numberFormat?: NumberFormatPresentation; /** Host translations of built-in copy, merged through nested providers. Components fall back to the English export per key; read the full resolved catalog with `useMessages()`. */
|
|
38
40
|
messages: Readonly<Partial<HIGMessages>>;
|
|
39
41
|
}
|
|
40
42
|
export interface HIGProviderProps extends Partial<Omit<HIGContext, 'messages'>> {
|
|
@@ -42,8 +44,12 @@ export interface HIGProviderProps extends Partial<Omit<HIGContext, 'messages'>>
|
|
|
42
44
|
messages?: Partial<HIGMessages>;
|
|
43
45
|
}
|
|
44
46
|
/** Direction defaults to the OS layout direction (I18nManager) so HIG roots never force LTR inside an RTL app. React Native 0.83 Android does not report a per-app RTL locale through I18nManager (#86): RTL hosts pass `direction={localeDirection(getLocales()[0])}`. Hosts that disallow RTL leave `direction` unset. */
|
|
45
|
-
export declare function HIGProvider({ children, density, locale, direction, reducedMotion, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace, primaryColor, marketColors, messages }: React.PropsWithChildren<HIGProviderProps>): React.JSX.Element;
|
|
47
|
+
export declare function HIGProvider({ children, density, locale, direction, reducedMotion, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace, primaryColor, marketColors, messages, numberFormat }: React.PropsWithChildren<HIGProviderProps>): React.JSX.Element;
|
|
46
48
|
export declare const useHIG: () => HIGContext;
|
|
49
|
+
/** Number options with the nearest provider's `numberFormat` merged under them; only currency formats change. */
|
|
50
|
+
export declare function usePresentNumber(): <T extends Intl.NumberFormatOptions | undefined>(options: T) => T;
|
|
51
|
+
/** The locale numbers are formatted in: the nearest provider's `numberFormat.locale`, else its `locale`. */
|
|
52
|
+
export declare function useNumberLocale(): string;
|
|
47
53
|
/** Marks content that sits on a Surface, Dialog or sheet. HIG has no resting strokes, so wells inside step up one fill to stay visible. */
|
|
48
54
|
export declare function Raised({ children }: React.PropsWithChildren): React.JSX.Element;
|
|
49
55
|
/** Fills for the current elevation: `well` for inputs, tracks and neutral chips; `raised` for what sits on a well (a selected segment). On the page they are `surface` and `nested`; inside a Surface, Dialog or sheet, `nested` and `border`. */
|
package/native/dist/provider.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { createContext, useContext, useEffect, useMemo, useState, useRef, useId } from 'react';
|
|
3
3
|
import { AccessibilityInfo, I18nManager, Platform } from 'react-native';
|
|
4
4
|
import { nativeSrgb, nativeDisplayP3, resolvePrimaryColor } from '@bloxwap/hig/tokens';
|
|
5
|
-
import { defaultEnvironment } from '@bloxwap/hig/contracts';
|
|
5
|
+
import { defaultEnvironment, numberLocale, presentNumberFormat } from '@bloxwap/hig/contracts';
|
|
6
6
|
import { defaultMessages, resolveMessages } from '@bloxwap/hig/contracts/messages';
|
|
7
7
|
/** Direction of a host-supplied locale (for example expo-localization's `getLocales()[0]`) for `HIGProvider direction`; see #86. */
|
|
8
8
|
export { localeDirection } from '@bloxwap/hig/contracts';
|
|
@@ -16,7 +16,7 @@ const marketColor = (value) => typeof value === 'string' && value !== '' ? value
|
|
|
16
16
|
const srgbColors = withMarketRoles(nativeSrgb), displayP3Colors = withMarketRoles(nativeDisplayP3);
|
|
17
17
|
const ColorsContext = createContext(srgbColors);
|
|
18
18
|
/** Direction defaults to the OS layout direction (I18nManager) so HIG roots never force LTR inside an RTL app. React Native 0.83 Android does not report a per-app RTL locale through I18nManager (#86): RTL hosts pass `direction={localeDirection(getLocales()[0])}`. Hosts that disallow RTL leave `direction` unset. */
|
|
19
|
-
export function HIGProvider({ children, density = 'comfortable', locale = 'en-US', direction = I18nManager.isRTL ? 'rtl' : 'ltr', reducedMotion, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace, primaryColor, marketColors, messages }) {
|
|
19
|
+
export function HIGProvider({ children, density = 'comfortable', locale = 'en-US', direction = I18nManager.isRTL ? 'rtl' : 'ltr', reducedMotion, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace, primaryColor, marketColors, messages, numberFormat }) {
|
|
20
20
|
const parent = useContext(Context);
|
|
21
21
|
const inherited = parent.messages;
|
|
22
22
|
const resolved = useMemo(() => resolveMessages(inherited, messages), [inherited, messages]);
|
|
@@ -31,9 +31,13 @@ export function HIGProvider({ children, density = 'comfortable', locale = 'en-US
|
|
|
31
31
|
const [osReduced, setOSReduced] = useState(false);
|
|
32
32
|
useEffect(() => { let alive = true; void AccessibilityInfo.isReduceMotionEnabled().then(v => { if (alive)
|
|
33
33
|
setOSReduced(v); }).catch(() => { }); const sub = AccessibilityInfo.addEventListener('reduceMotionChanged', setOSReduced); return () => { alive = false; sub.remove(); }; }, []);
|
|
34
|
-
return _jsx(Context.Provider, { value: { density, locale, direction, reducedMotion: reducedMotion ?? osReduced, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript: fontFamiliesByScript ?? parent.fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace: space, primaryColor: normalized, marketColors: inheritedMarket, messages: resolved }, children: _jsx(ColorsContext.Provider, { value: colors, children: children }) });
|
|
34
|
+
return _jsx(Context.Provider, { value: { density, locale, direction, reducedMotion: reducedMotion ?? osReduced, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript: fontFamiliesByScript ?? parent.fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace: space, primaryColor: normalized, marketColors: inheritedMarket, messages: resolved, numberFormat: numberFormat ?? parent.numberFormat }, children: _jsx(ColorsContext.Provider, { value: colors, children: children }) });
|
|
35
35
|
}
|
|
36
36
|
export const useHIG = () => useContext(Context);
|
|
37
|
+
/** Number options with the nearest provider's `numberFormat` merged under them; only currency formats change. */
|
|
38
|
+
export function usePresentNumber() { const { numberFormat } = useContext(Context); return useMemo(() => (options) => presentNumberFormat(options, numberFormat), [numberFormat]); }
|
|
39
|
+
/** The locale numbers are formatted in: the nearest provider's `numberFormat.locale`, else its `locale`. */
|
|
40
|
+
export function useNumberLocale() { const { locale, numberFormat } = useContext(Context); return numberLocale(locale, numberFormat); }
|
|
37
41
|
const RaisedContext = createContext(false);
|
|
38
42
|
/** Marks content that sits on a Surface, Dialog or sheet. HIG has no resting strokes, so wells inside step up one fill to stay visible. */
|
|
39
43
|
export function Raised({ children }) { return _jsx(RaisedContext.Provider, { value: true, children: children }); }
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type ScrollViewProps } from 'react-native';
|
|
2
3
|
import type { ChoicesProps } from './selection-types.js';
|
|
3
4
|
export declare function RadioGroup({ label, options, value, defaultValue, disabled, onValueChange }: ChoicesProps): React.JSX.Element;
|
|
4
5
|
/** Equal-width choices with one interruptible selection indicator. The track is the dark well and the selected segment the lighter fill; the control is 44dp tall (36 compact). */
|
|
5
|
-
export
|
|
6
|
+
export interface SegmentedControlProps extends ChoicesProps {
|
|
7
|
+
hideLabel?: boolean;
|
|
8
|
+
testID?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function SegmentedControl({ label, options, value, defaultValue, disabled, hideLabel, testID, onValueChange }: SegmentedControlProps): React.JSX.Element;
|
|
6
11
|
export interface FilterOption {
|
|
7
12
|
value: string;
|
|
8
13
|
label: string;
|
|
@@ -15,7 +20,8 @@ export interface FilterProps {
|
|
|
15
20
|
value?: string;
|
|
16
21
|
defaultValue?: string;
|
|
17
22
|
disabled?: boolean;
|
|
18
|
-
onValueChange?: (value: string) => void;
|
|
23
|
+
onValueChange?: (value: string) => void; /** The horizontal scroll view the capsules sit in, such as a sheet library's ScrollView that keeps sideways drags from the sheet. It receives the same props as React Native's `ScrollView`, which is the default. */
|
|
24
|
+
scrollComponent?: React.ComponentType<ScrollViewProps>;
|
|
19
25
|
}
|
|
20
26
|
/** A horizontal, scrolling row of single-choice filter chips. The selected chip inverts and its circle shows a check that animates in. */
|
|
21
|
-
export declare function Filter({ label, options, value, defaultValue, disabled, onValueChange }: FilterProps): React.JSX.Element;
|
|
27
|
+
export declare function Filter({ label, options, value, defaultValue, disabled, onValueChange, scrollComponent: Scroll }: FilterProps): React.JSX.Element;
|
|
@@ -18,8 +18,7 @@ export function RadioGroup({ label, options, value, defaultValue = '', disabled,
|
|
|
18
18
|
}
|
|
19
19
|
/** Segments are 36dp inside a 44dp track; the slop restores a 48dp touch target. */
|
|
20
20
|
const segmentSlop = { top: 6, bottom: 6 };
|
|
21
|
-
|
|
22
|
-
export function SegmentedControl({ label, options, value, defaultValue = '', disabled, onValueChange }) {
|
|
21
|
+
export function SegmentedControl({ label, options, value, defaultValue = '', disabled, hideLabel, testID, onValueChange }) {
|
|
23
22
|
const [current, set] = useControllable(value, defaultValue, onValueChange);
|
|
24
23
|
const { direction, locale, reducedMotion, density } = useHIG();
|
|
25
24
|
const colors = useColors();
|
|
@@ -47,7 +46,7 @@ export function SegmentedControl({ label, options, value, defaultValue = '', dis
|
|
|
47
46
|
animation.start();
|
|
48
47
|
return () => animation.stop();
|
|
49
48
|
}, [selected, width, count, direction, reducedMotion, target, translateX]);
|
|
50
|
-
return _jsxs(View, { accessibilityRole: 'radiogroup', accessibilityLabel: label, style: { direction, gap: 8 }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: label }), _jsx(View, { style: { padding: 4, borderRadius: 9999, backgroundColor: fills.well }, children: _jsxs(View, { onLayout: event => setWidth(event.nativeEvent.layout.width), style: { flexDirection: 'row', gap: 4 }, children: [selected >= 0 && width > 0 && _jsx(Animated.View, { pointerEvents: 'none', accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', style: { position: 'absolute', ...anchor, top: 0, bottom: 0, width: segmentWidth, borderRadius: 9999, backgroundColor: fills.raised, opacity: disabled || options[selected].disabled ? 0.5 : 1, transform: [{ translateX }] } }), options.map(option => {
|
|
49
|
+
return _jsxs(View, { testID: testID, accessibilityRole: 'radiogroup', accessibilityLabel: label, style: { direction, gap: 8 }, children: [hideLabel ? null : _jsx(Text, { style: { fontWeight: '600' }, children: label }), _jsx(View, { style: { padding: 4, borderRadius: 9999, backgroundColor: fills.well }, children: _jsxs(View, { onLayout: event => setWidth(event.nativeEvent.layout.width), style: { flexDirection: 'row', gap: 4 }, children: [selected >= 0 && width > 0 && _jsx(Animated.View, { pointerEvents: 'none', accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', style: { position: 'absolute', ...anchor, top: 0, bottom: 0, width: segmentWidth, borderRadius: 9999, backgroundColor: fills.raised, opacity: disabled || options[selected].disabled ? 0.5 : 1, transform: [{ translateX }] } }), options.map(option => {
|
|
51
50
|
const checked = current === option.value, blocked = !!disabled || !!option.disabled;
|
|
52
51
|
const activate = () => { if (!blocked)
|
|
53
52
|
set(option.value); };
|
|
@@ -84,8 +83,8 @@ function FilterChip({ option, checked, blocked, reducedMotion, onSelect }) {
|
|
|
84
83
|
activate(); }, hitSlop: filterSlop, style: state => ({ flexDirection: 'row', alignItems: 'center', gap: 8, minHeight: 40, paddingVertical: 6, paddingStart: 8, paddingEnd: 16, borderRadius: 9999, backgroundColor: checked ? colors.text : state.pressed ? fills.raised : fills.well, opacity: blocked ? 0.5 : 1 }), children: [_jsxs(View, { ...hiddenMark, style: { width: 24, height: 24, borderRadius: 12, overflow: 'hidden', alignItems: 'center', justifyContent: 'center' }, children: [option.icon ? _jsx(Image, { source: { uri: option.icon }, accessible: false, style: { position: 'absolute', width: 24, height: 24, borderRadius: 12 } }) : _jsx(View, { style: { position: 'absolute', width: 24, height: 24, borderRadius: 12, borderWidth: 2, borderColor: ink } }), _jsx(Animated.View, { style: { position: 'absolute', width: 24, height: 24, borderRadius: 12, backgroundColor: colors.background, opacity: progress } }), _jsx(Animated.View, { style: { opacity: progress, transform: [{ scale: progress.interpolate({ inputRange: [0, 1], outputRange: [0.4, 1] }) }] }, children: _jsx(View, { style: { width: 11, height: 6, borderLeftWidth: 2, borderBottomWidth: 2, borderColor: colors.text, transform: [{ translateY: -1.5 }, { rotate: '-45deg' }] } }) })] }), _jsx(Text, { accessible: false, style: { fontSize: 14, lineHeight: 21, fontWeight: '600', color: ink }, children: option.label })] });
|
|
85
84
|
}
|
|
86
85
|
/** A horizontal, scrolling row of single-choice filter chips. The selected chip inverts and its circle shows a check that animates in. */
|
|
87
|
-
export function Filter({ label, options, value, defaultValue = '', disabled, onValueChange }) {
|
|
86
|
+
export function Filter({ label, options, value, defaultValue = '', disabled, onValueChange, scrollComponent: Scroll = ScrollView }) {
|
|
88
87
|
const [current, set] = useControllable(value, defaultValue, onValueChange);
|
|
89
88
|
const { direction, reducedMotion } = useHIG();
|
|
90
|
-
return _jsx(
|
|
89
|
+
return _jsx(Scroll, { horizontal: true, showsHorizontalScrollIndicator: false, keyboardShouldPersistTaps: 'handled', accessibilityRole: 'radiogroup', accessibilityLabel: label, style: { flexGrow: 0, direction }, contentContainerStyle: { direction, gap: 8 }, children: options.map(option => _jsx(FilterChip, { option: option, checked: current === option.value, blocked: !!disabled || !!option.disabled, reducedMotion: !!reducedMotion, onSelect: () => set(option.value) }, option.value)) });
|
|
91
90
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Blocks were called recipes through 0.5.x. Import from `@bloxwap/hig/native/blocks`; this module is removed in the next
|
|
3
|
+
* major release. It exists as a real file so a Jest `moduleNameMapper` that maps `@bloxwap/hig/native/<entry>` to `native/dist/<entry>.js`
|
|
4
|
+
* resolves the old path too.
|
|
5
|
+
*/
|
|
6
|
+
export * from './blocks.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Blocks were called recipes through 0.5.x. Import from `@bloxwap/hig/native/blocks`; this module is removed in the next
|
|
3
|
+
* major release. It exists as a real file so a Jest `moduleNameMapper` that maps `@bloxwap/hig/native/<entry>` to `native/dist/<entry>.js`
|
|
4
|
+
* resolves the old path too.
|
|
5
|
+
*/
|
|
6
|
+
export * from './blocks.js';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type ScrollViewProps } from 'react-native';
|
|
2
3
|
import type { AssetArtwork } from './asset-balance-row.js';
|
|
4
|
+
import { type Figure } from './figure.js';
|
|
3
5
|
/** The promotion above the standings: a prize pool filling towards a goal, or a draw with a top prize. Every word is host text. */
|
|
4
6
|
export interface RewardPromo {
|
|
5
7
|
/** The small capitals line: Season 01. */
|
|
@@ -17,8 +19,8 @@ export interface RewardPromo {
|
|
|
17
19
|
goal?: number;
|
|
18
20
|
/** The line under the figure. A function receives the formatted goal: `goal => 'of ' + goal + ' prize pool'`. A string is drawn as given: top prize. */
|
|
19
21
|
caption?: string | ((goal: string) => string);
|
|
20
|
-
/** The lead of the explaining sentence, in the text colour: Top 100 traders split the pool. */
|
|
21
|
-
headline?:
|
|
22
|
+
/** The lead of the explaining sentence, in the text colour: Top 100 traders split the pool. Host text, or host Text elements for an accented word. */
|
|
23
|
+
headline?: React.ReactNode;
|
|
22
24
|
/** Continues the sentence after the headline in the muted colour: Funded by builder fees on every trade. */
|
|
23
25
|
description?: string;
|
|
24
26
|
/** A full-width action under the description: Draws and winners. The host opens its own destination. */
|
|
@@ -27,6 +29,14 @@ export interface RewardPromo {
|
|
|
27
29
|
onSelect: () => void;
|
|
28
30
|
};
|
|
29
31
|
}
|
|
32
|
+
/** A host figure that updates place by place: `{value:1090779, options:{style:'currency',currency:'USD',maximumFractionDigits:0}, suffix:' vol'}`. */
|
|
33
|
+
export type RewardFigure = Figure;
|
|
34
|
+
/** One step of the paging control under the list. */
|
|
35
|
+
export interface RewardPageStep {
|
|
36
|
+
label: string;
|
|
37
|
+
onSelect: () => void;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
}
|
|
30
40
|
/** One trader in the standings. */
|
|
31
41
|
export interface RewardEntry {
|
|
32
42
|
id: string;
|
|
@@ -37,10 +47,12 @@ export interface RewardEntry {
|
|
|
37
47
|
avatar?: AssetArtwork;
|
|
38
48
|
/** Shows the verified mark after the name. */
|
|
39
49
|
verified?: boolean;
|
|
40
|
-
/** The line under the name: `$1,090,779 vol
|
|
41
|
-
detail?: string;
|
|
50
|
+
/** The line under the name: `$1,090,779 vol` as text, or the same as a live figure. */
|
|
51
|
+
detail?: string | RewardFigure;
|
|
42
52
|
/** Points or entries. `null` reads as unknown. */
|
|
43
53
|
score: number | null;
|
|
54
|
+
/** Format of this entry's score, in place of the block's `scoreOptions`, for a prize list where some amounts have cents. */
|
|
55
|
+
scoreOptions?: Intl.NumberFormatOptions;
|
|
44
56
|
/** Marks the viewer's own row: the name and score take the action colour. */
|
|
45
57
|
you?: boolean;
|
|
46
58
|
}
|
|
@@ -60,12 +72,38 @@ export interface RewardBlockProps {
|
|
|
60
72
|
};
|
|
61
73
|
/** The viewer's own standing, pinned above the list on a tinted row. */
|
|
62
74
|
you?: RewardEntry;
|
|
75
|
+
/** Names the pinned row for assistive technology, read before its rank: Your rank. */
|
|
76
|
+
youLabel?: string;
|
|
77
|
+
/** A muted line between the pinned row and the list, announced when it changes: You're not ranked yet. */
|
|
78
|
+
status?: string;
|
|
79
|
+
/** Host artwork in place of the built-in verified mark, inside the row's one accessible element. */
|
|
80
|
+
verifiedMark?: React.ReactNode;
|
|
81
|
+
/** The `verifiedMark` is a control, such as a badge that opens an explanation: it stays in the accessibility tree, the row's reading then sits on the name and the mark follows as its own element. */
|
|
82
|
+
verifiedMarkInteractive?: boolean;
|
|
83
|
+
/** Draws skeleton rows in place of the entries while the host loads them. */
|
|
84
|
+
loading?: boolean;
|
|
85
|
+
/** Host text that names the skeleton rows for assistive technology: Loading standings. Without it they are only marked busy. */
|
|
86
|
+
loadingLabel?: string;
|
|
87
|
+
/** Paging under the list: Previous and Next as buttons with the host's range between them, such as 1–25. */
|
|
88
|
+
pagination?: {
|
|
89
|
+
previous?: RewardPageStep;
|
|
90
|
+
next?: RewardPageStep;
|
|
91
|
+
label?: string;
|
|
92
|
+
};
|
|
93
|
+
/** Keeps the header pinned while the rest scrolls: the block becomes its own scroll view (`scrollComponent`) with the header as a sticky first child, transparent at rest and filled once the standings scroll under it. Place it in a bounded container, such as a sheet body. */
|
|
94
|
+
stickyHeader?: boolean;
|
|
95
|
+
/** Fill behind the pinned header once rows scroll under it. Defaults to the background role; in a sheet pass the sheet's fill (`useColors().overlay`). */
|
|
96
|
+
stickyHeaderBackground?: string;
|
|
97
|
+
/** Set false to leave the header out, when the host pins its own `ScreenHeader` above the block. The content then starts at the block's top edge. */
|
|
98
|
+
header?: boolean;
|
|
99
|
+
/** The scroll view used with `stickyHeader`, such as a sheet library's own. Defaults to React Native's ScrollView. */
|
|
100
|
+
scrollComponent?: React.ComponentType<ScrollViewProps>;
|
|
63
101
|
/** The column heading over the names: Top 25 by volume. */
|
|
64
102
|
listTitle?: string;
|
|
65
103
|
/** The column heading over the scores: Entries. */
|
|
66
104
|
scoreTitle?: string;
|
|
67
105
|
entries: readonly RewardEntry[];
|
|
68
|
-
/** Format of every score. Defaults to a whole number. */
|
|
106
|
+
/** Format of every score. Defaults to a whole number. An entry's own `scoreOptions` wins. */
|
|
69
107
|
scoreOptions?: Intl.NumberFormatOptions;
|
|
70
108
|
/** Words for the verified mark, read after the name. */
|
|
71
109
|
verifiedLabel?: string;
|
|
@@ -75,9 +113,10 @@ export interface RewardBlockProps {
|
|
|
75
113
|
onBack?: () => void;
|
|
76
114
|
/** A control on the trailing edge of the header, usually an IconButton that shares. */
|
|
77
115
|
headerAction?: React.ReactNode;
|
|
116
|
+
/** Prefixes every test ID inside the block: `<testID>-header`, `<testID>-back`, `<testID>-title`, `<testID>-row-<id>` and so on. Omitted, they start with `reward`. */
|
|
78
117
|
testID?: string;
|
|
79
118
|
}
|
|
80
119
|
/** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
|
|
81
120
|
export declare function rewardProgress(amount: number | null | undefined, goal: number | null | undefined): number | null;
|
|
82
121
|
/** A competition as a screen: an optional promotion (a prize pool filling towards its goal, or a draw with its top prize), an optional choice of standings, the viewer's own standing pinned on a tinted row, and the ranked list. */
|
|
83
|
-
export declare function RewardBlock({ title, promo, tabs, you, listTitle, scoreTitle, entries, scoreOptions, verifiedLabel, footnote, onBack, headerAction, testID }: RewardBlockProps): React.JSX.Element;
|
|
122
|
+
export declare function RewardBlock({ title, promo, tabs, you, youLabel, status, listTitle, scoreTitle, entries, scoreOptions, verifiedLabel, verifiedMark, verifiedMarkInteractive, loading, loadingLabel, pagination, footnote, onBack, headerAction, stickyHeader, stickyHeaderBackground, scrollComponent, header: showHeader, testID }: RewardBlockProps): React.JSX.Element;
|
|
@@ -1,14 +1,17 @@
|
|
|
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 { Image, Pressable, View } from 'react-native';
|
|
3
3
|
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
4
4
|
import { withAlpha } from '@bloxwap/hig/tokens';
|
|
5
|
-
import { useColors, useFills, useHIG,
|
|
5
|
+
import { useColors, useFills, useHIG, useNumberLocale, usePresentNumber } from './provider.js';
|
|
6
6
|
import { Surface, Text } from './surface.js';
|
|
7
|
-
import {
|
|
7
|
+
import { Button } from './button.js';
|
|
8
8
|
import { SegmentedControl } from './radio-group.js';
|
|
9
9
|
import { ChevronIcon, SeverityIcon } from './icons.js';
|
|
10
10
|
import { AnimatedNumberReadout } from './animated-number.js';
|
|
11
11
|
import { formatNumberReadout } from './animated-number-model.js';
|
|
12
|
+
import { ScreenHeader } from './screen-header.js';
|
|
13
|
+
import { StickyHeaderLayout } from './sticky-header.js';
|
|
14
|
+
import { figureProps } from './figure.js';
|
|
12
15
|
const wholeDollars = { style: 'currency', currency: 'USD', maximumFractionDigits: 0 };
|
|
13
16
|
const whole = { maximumFractionDigits: 0 };
|
|
14
17
|
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
@@ -18,18 +21,33 @@ export function rewardProgress(amount, goal) {
|
|
|
18
21
|
return amount == null || goal == null || !Number.isFinite(amount) || !Number.isFinite(goal) || !(goal > 0) ? null : Math.min(1, Math.max(0, amount / goal));
|
|
19
22
|
}
|
|
20
23
|
/** A competition as a screen: an optional promotion (a prize pool filling towards its goal, or a draw with its top prize), an optional choice of standings, the viewer's own standing pinned on a tinted row, and the ranked list. */
|
|
21
|
-
export function RewardBlock({ title, promo, tabs, you, listTitle, scoreTitle, entries, scoreOptions = whole, verifiedLabel, footnote, onBack, headerAction, testID }) {
|
|
22
|
-
const colors = useColors(), fills = useFills(),
|
|
24
|
+
export function RewardBlock({ title, promo, tabs, you, youLabel, status, listTitle, scoreTitle, entries, scoreOptions = whole, verifiedLabel, verifiedMark, verifiedMarkInteractive, loading, loadingLabel, pagination, footnote, onBack, headerAction, stickyHeader, stickyHeaderBackground, scrollComponent, header: showHeader = true, testID }) {
|
|
25
|
+
const colors = useColors(), fills = useFills(), { direction, monoFontFamily } = useHIG(), locale = useNumberLocale(), present = usePresentNumber();
|
|
26
|
+
const prefix = testID ?? 'reward', tid = (part) => `${prefix}-${part}`;
|
|
23
27
|
const money = promo?.amountOptions ?? wholeDollars, reached = promo ? rewardProgress(promo.amount, promo.goal) : null;
|
|
24
|
-
const caption = typeof promo?.caption === 'function' ? promo.goal !== undefined ? promo.caption(formatNumber(promo.goal, locale, money)) : undefined : promo?.caption;
|
|
28
|
+
const caption = typeof promo?.caption === 'function' ? promo.goal !== undefined ? promo.caption(formatNumber(promo.goal, locale, present(money))) : undefined : promo?.caption;
|
|
25
29
|
const caps = { fontFamily: monoFontFamily, fontSize: 12, lineHeight: 16, letterSpacing: 1.5, textTransform: 'uppercase' };
|
|
26
|
-
const standing = (entry, id, style) => {
|
|
27
|
-
const
|
|
30
|
+
const standing = (entry, id, style, lead) => {
|
|
31
|
+
const figure = entry.detail != null && typeof entry.detail === 'object' ? entry.detail : null, detail = typeof entry.detail === 'string' ? entry.detail : undefined, score = entry.scoreOptions ?? scoreOptions;
|
|
32
|
+
const said = figure ? formatNumberReadout(figure.value, locale, present(figure.options), figure.formattedValue, figure.prefix, figure.suffix).text : detail;
|
|
33
|
+
const mine = !!entry.you, reading = [lead, String(entry.rank), entry.name, entry.verified && verifiedLabel ? verifiedLabel : null, said, formatNumberReadout(entry.score, locale, present(score)).text].filter(Boolean).join(', ');
|
|
28
34
|
const disc = { width: avatar, height: avatar, borderRadius: avatar / 2, backgroundColor: fills.raised, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' };
|
|
29
|
-
|
|
35
|
+
// An interactive host mark stays in the accessibility tree: the row's reading moves to the name, and the mark follows as its own element.
|
|
36
|
+
const split = !!entry.verified && verifiedMark != null && !!verifiedMarkInteractive;
|
|
37
|
+
return _jsxs(View, { testID: id, accessible: !split, accessibilityLabel: split ? undefined : reading, style: { direction, flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 64, paddingVertical: 8, paddingHorizontal: 20, backgroundColor: fills.well, ...style }, children: [_jsx(Text, { ...hidden, style: { minWidth: 24, fontFamily: monoFontFamily, fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.muted }, children: entry.rank }), _jsx(View, { ...hidden, children: typeof entry.avatar === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: entry.avatar }, style: disc }) : _jsx(View, { style: disc, children: entry.avatar ?? _jsx(Text, { maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: entry.name.slice(0, 2) }) }) }), _jsxs(View, { ...(split ? null : hidden), style: { flex: 1, flexShrink: 1, minWidth: 0 }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 6 }, children: [_jsx(Text, { testID: `${id}-name`, accessible: split, accessibilityLabel: split ? reading : undefined, numberOfLines: 1, style: { flexShrink: 1, fontFamily: monoFontFamily, fontSize: 16, lineHeight: 24, fontWeight: '600', color: mine ? colors.action : colors.text }, children: entry.name }), entry.verified ? (verifiedMark != null ? _jsx(View, { testID: `${id}-verified`, children: verifiedMark }) : _jsx(View, { testID: `${id}-verified`, style: { transform: [{ scale: 0.8 }] }, children: _jsx(SeverityIcon, { kind: 'success', color: colors.warning }) })) : null] }), figure ? _jsx(View, { ...hidden, style: { alignItems: 'flex-start' }, children: _jsx(AnimatedNumberReadout, { testID: `${id}-detail`, ...figureProps(figure), tone: 'muted', style: { fontFamily: monoFontFamily, fontSize: 14, lineHeight: 20 } }) })
|
|
38
|
+
: detail ? _jsx(Text, { ...hidden, numberOfLines: 1, style: { fontFamily: monoFontFamily, fontSize: 14, lineHeight: 20, color: colors.muted }, children: detail }) : null] }), _jsx(View, { ...hidden, children: _jsx(AnimatedNumberReadout, { value: entry.score, options: score, tone: mine ? 'positive' : 'text', testID: `${id}-score`, style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) })] }, entry.id);
|
|
30
39
|
};
|
|
31
40
|
// Rows are built here so their test ids are code, not JSX text.
|
|
32
|
-
const pinned = you ? standing({ ...you, you: true }, '
|
|
33
|
-
const rows = entries.map(entry => standing(entry, `
|
|
34
|
-
|
|
41
|
+
const pinned = you ? standing({ ...you, you: true }, tid('you'), { marginTop: 16, borderRadius: 20, backgroundColor: withAlpha(colors.action, 0.12) }, youLabel) : null;
|
|
42
|
+
const rows = entries.map(entry => standing(entry, tid(`row-${entry.id}`)));
|
|
43
|
+
const header = _jsx(ScreenHeader, { testID: prefix, title: title, onBack: onBack, action: headerAction });
|
|
44
|
+
const small = { fontSize: 14, lineHeight: 21, color: colors.muted };
|
|
45
|
+
const list = loading ? _jsx(View, { testID: tid('loading'), accessible: !!loadingLabel, accessibilityLabel: loadingLabel, accessibilityState: { busy: true }, style: { gap: 2, marginTop: 16, borderRadius: 20, overflow: 'hidden' }, children: [0, 1, 2, 3, 4].map(index => _jsx(View, { style: { minHeight: 64, backgroundColor: fills.raised } }, index)) }) : entries.length > 0 || listTitle || scoreTitle ? _jsxs(View, { testID: tid('list'), style: { gap: 8, marginTop: 16 }, children: [listTitle || scoreTitle ? _jsxs(View, { style: { direction, flexDirection: 'row', justifyContent: 'space-between', gap: 12, paddingHorizontal: 4 }, children: [_jsx(Text, { testID: tid('list-title'), style: { ...caps, flexShrink: 1, color: colors.muted }, children: listTitle }), _jsx(Text, { testID: tid('score-title'), style: { ...caps, flexShrink: 1, color: colors.muted, textAlign: 'right' }, children: scoreTitle })] }) : null, entries.length > 0 ? _jsx(View, { testID: tid('rows'), style: { gap: 2, borderRadius: 20, overflow: 'hidden' }, children: rows }) : null] }) : null;
|
|
46
|
+
const pages = pagination ? _jsxs(View, { testID: tid('pagination'), style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 8, marginTop: 16 }, children: [_jsx(View, { style: { flex: 1, alignItems: 'flex-start' }, children: pagination.previous ? _jsx(Button, { testID: tid('previous'), intent: 'secondary', disabled: pagination.previous.disabled, onPress: pagination.previous.onSelect, children: pagination.previous.label }) : null }), pagination.label ? _jsx(Text, { testID: tid('page'), accessibilityLiveRegion: 'polite', style: { ...small, fontFamily: monoFontFamily, textAlign: 'center' }, children: pagination.label }) : null, _jsx(View, { style: { flex: 1, alignItems: 'flex-end' }, children: pagination.next ? _jsx(Button, { testID: tid('next'), intent: 'secondary', disabled: pagination.next.disabled, onPress: pagination.next.onSelect, children: pagination.next.label }) : null })] }) : null;
|
|
47
|
+
const body = _jsxs(_Fragment, { children: [promo ? _jsxs(Surface, { testID: tid('promo'), style: { gap: 12, marginTop: 16 }, children: [_jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12 }, children: [_jsx(Text, { testID: tid('eyebrow'), style: { ...caps, flexShrink: 1, color: colors.muted }, children: promo.eyebrow }), promo.rules ? _jsxs(Pressable, { testID: tid('rules'), accessibilityRole: 'button', hitSlop: 12, onPress: promo.rules.onSelect, style: ({ pressed }) => ({ flexDirection: 'row', alignItems: 'center', gap: 4, opacity: pressed ? 0.6 : 1 }), children: [_jsx(Text, { style: { fontSize: 16, lineHeight: 24, fontWeight: '500', color: colors.muted }, children: promo.rules.label }), _jsx(View, { ...hidden, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] }) : null] }), _jsxs(View, { testID: tid('amount'), accessible: true, accessibilityLabel: [formatNumberReadout(promo.amount, locale, present(money)).text, caption].filter(Boolean).join(' '), style: { gap: 4 }, children: [_jsx(View, { ...hidden, style: { alignItems: 'flex-start' }, children: _jsx(AnimatedNumberReadout, { value: promo.amount, options: money, tone: 'positive', style: { fontSize: 44, lineHeight: 50, fontWeight: '700', letterSpacing: -0.9 } }) }), caption ? _jsx(Text, { ...hidden, testID: tid('caption'), style: { fontFamily: monoFontFamily, fontSize: 15, lineHeight: 22, color: colors.muted }, children: caption }) : null] }), promo.goal !== undefined ? _jsx(View, { ...hidden, testID: tid('track'), style: { direction, flexDirection: 'row', height: 4, borderRadius: 2, backgroundColor: fills.raised, overflow: 'hidden' }, children: _jsx(View, { testID: tid('fill'), style: { width: `${(reached ?? 0) * 100}%`, minWidth: 8, borderRadius: 2, backgroundColor: colors.action } }) }) : null, promo.headline || promo.description ? _jsxs(Text, { testID: tid('summary'), style: { fontSize: 16, lineHeight: 24, color: colors.muted }, children: [promo.headline ? _jsx(Text, { style: { fontWeight: '600', color: colors.text }, children: promo.headline }) : null, promo.headline && promo.description ? space : null, promo.description] }) : null, promo.action ? _jsxs(Pressable, { testID: tid('action'), accessibilityRole: 'button', accessibilityLabel: promo.action.label, onPress: promo.action.onSelect, style: { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 44, marginTop: 4, marginBottom: -8, paddingTop: 12, borderTopWidth: 1, borderTopColor: fills.raised }, children: [_jsx(Text, { ...hidden, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '500', color: colors.muted }, children: promo.action.label }), _jsx(View, { ...hidden, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] }) : null] }) : null, tabs ? _jsx(View, { testID: tid('tabs'), style: { marginTop: 16 }, children: _jsx(SegmentedControl, { label: tabs.label, options: tabs.options, value: tabs.value, onValueChange: tabs.onValueChange }) }) : null, pinned, status ? _jsx(Text, { testID: tid('status'), accessibilityLiveRegion: 'polite', style: { ...small, marginTop: 16, paddingHorizontal: 4 }, children: status }) : null, list, pages, footnote ? _jsx(Text, { testID: tid('footnote'), style: { fontSize: 14, lineHeight: 21, color: colors.muted, marginTop: 16, paddingHorizontal: 4 }, children: footnote }) : null] });
|
|
48
|
+
if (!showHeader)
|
|
49
|
+
return _jsx(View, { testID: testID, style: { padding: 16, paddingTop: 0 }, children: body });
|
|
50
|
+
if (stickyHeader)
|
|
51
|
+
return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: tid('sticky-header'), header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: body });
|
|
52
|
+
return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [header, body] });
|
|
35
53
|
}
|