@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
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Pressable, View } from 'react-native';
|
|
3
|
+
import { useColors, useFills, useHIG, useMessages } from './provider.js';
|
|
4
|
+
import { Text } from './surface.js';
|
|
5
|
+
import { Button } from './button.js';
|
|
6
|
+
import { PresetGroup } from './preset-group.js';
|
|
7
|
+
import { ChevronIcon } from './icons.js';
|
|
8
|
+
import { AnimatedNumberReadout } from './animated-number.js';
|
|
9
|
+
import { ScreenHeader } from './screen-header.js';
|
|
10
|
+
import { StickyHeaderLayout } from './sticky-header.js';
|
|
11
|
+
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
12
|
+
/**
|
|
13
|
+
* Choose one value from quick choices as a screen: an optional header, the value as the headline figure, an optional row that opens the
|
|
14
|
+
* 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
|
|
15
|
+
* TargetBlock's parts (the headline, the Custom row, PresetGroup and the actions row) without its price card and unit control.
|
|
16
|
+
*/
|
|
17
|
+
export function PresetPickerBlock({ title, value, valueOptions, valuePrefix, valueSuffix, valueLabel, formattedValue, animateFormatted, presets, selected, onPresetChange, presetsLabel, columns, adjustable, custom, intent = 'primary', children, onSubmit, submitLabel, submitDisabled, busy, onCancel, cancelLabel, suppressFeedback, onBack, backProps, headerAction, headingId, stickyHeader, stickyHeaderBackground, scrollComponent, testID = 'preset-picker' }) {
|
|
18
|
+
const colors = useColors(), fills = useFills(), t = useMessages(), { direction } = useHIG();
|
|
19
|
+
const id = (part) => `${testID}-${part}`;
|
|
20
|
+
const destructive = intent === 'destructive', onFill = destructive ? colors.background : colors.onAction;
|
|
21
|
+
const customSelected = custom ? (custom.selected ?? custom.value !== undefined) : false;
|
|
22
|
+
const chevron = (color) => _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: color }) });
|
|
23
|
+
const label = presetsLabel ?? title;
|
|
24
|
+
const group = presets.length > 0 ? _jsx(PresetGroup, { testID: id('presets'), label: label, options: presets.map(option => ({ ...option, testID: option.testID ?? id(`preset-${option.value}`) })), value: selected, onValueChange: onPresetChange, columns: columns, selectedIntent: intent, suppressFeedback: suppressFeedback }) : null;
|
|
25
|
+
// The adjust gesture steps from the selected chip (or the first, when none is) to the next enabled one.
|
|
26
|
+
const enabled = presets.filter(option => !option.disabled), at = enabled.findIndex(option => selected !== null && Object.is(option.value, selected));
|
|
27
|
+
const step = (delta) => { const next = enabled[at < 0 ? 0 : Math.max(0, Math.min(enabled.length - 1, at + delta))]; if (next && !Object.is(next.value, selected))
|
|
28
|
+
onPresetChange(next.value); };
|
|
29
|
+
const current = presets.find(option => selected !== null && Object.is(option.value, selected));
|
|
30
|
+
// With a range the value is reported as min, max and now beside the chip's label; without one, as the label alone.
|
|
31
|
+
const range = (chip) => {
|
|
32
|
+
if (!adjustable || (adjustable.min === undefined && adjustable.max === undefined && adjustable.now === undefined))
|
|
33
|
+
return chip ? { text: chip.label } : undefined;
|
|
34
|
+
const now = adjustable.now ?? (typeof chip?.value === 'number' ? chip.value : undefined);
|
|
35
|
+
return { min: adjustable.min, max: adjustable.max, ...(now !== undefined ? { now } : {}), ...(chip ? { text: chip.label } : {}) };
|
|
36
|
+
};
|
|
37
|
+
const chips = adjustable && group ? _jsx(View, { testID: adjustable.testID ?? id('adjustable'), accessible: true, accessibilityRole: 'adjustable', accessibilityLabel: label, accessibilityValue: range(current), accessibilityActions: [{ name: 'increment', label: adjustable.incrementLabel }, { name: 'decrement', label: adjustable.decrementLabel }], onAccessibilityAction: event => step(event.nativeEvent.actionName === 'increment' ? 1 : -1), children: group }) : group;
|
|
38
|
+
const header = title !== undefined ? _jsx(ScreenHeader, { title: title, onBack: onBack, backProps: backProps, action: headerAction, headingId: headingId, testID: testID }) : null;
|
|
39
|
+
const body = _jsxs(_Fragment, { children: [_jsx(View, { style: { alignItems: 'center' }, children: _jsx(AnimatedNumberReadout, { testID: id('headline'), value: value, options: valueOptions, formattedValue: formattedValue, animateFormatted: animateFormatted, prefix: valuePrefix, suffix: valueSuffix, label: valueLabel, style: { fontSize: 44, lineHeight: 50, fontWeight: '700', letterSpacing: -0.9, textAlign: 'center' } }) }), custom ? _jsxs(Pressable, { ...custom.pressProps, testID: custom.testID ?? id('custom'), accessibilityRole: 'button', accessibilityLabel: custom.accessibilityLabel ?? (custom.value !== undefined ? `${custom.label}, ${custom.value}` : undefined), accessibilityState: { selected: customSelected }, onPress: custom.onSelect, style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 48, paddingHorizontal: 16, borderRadius: 9999, backgroundColor: customSelected ? (destructive ? colors.negative : colors.action) : pressed ? fills.raised : fills.well, opacity: customSelected && pressed ? 0.9 : 1 }), children: [_jsx(Text, { ...hidden, numberOfLines: 1, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '600', color: customSelected ? onFill : colors.text }, children: custom.label }), _jsxs(View, { ...hidden, style: { direction, flexDirection: 'row', alignItems: 'center', gap: 6, flexShrink: 1 }, children: [custom.value !== undefined ? _jsx(Text, { testID: id('custom-value'), numberOfLines: 1, style: { flexShrink: 1, fontSize: 16, lineHeight: 24, fontWeight: '500', color: customSelected ? onFill : colors.muted }, children: custom.value }) : null, chevron(customSelected ? onFill : colors.muted)] })] }) : null, chips, children, _jsxs(View, { testID: id('actions'), style: { direction, flexDirection: 'row', gap: 8 }, children: [onCancel ? _jsx(Button, { testID: id('cancel'), intent: 'secondary', suppressFeedback: suppressFeedback, onPress: onCancel, style: { flex: 1, alignSelf: 'auto' }, children: cancelLabel ?? t.cancel }) : null, _jsx(Button, { testID: id('confirm'), intent: intent, disabled: submitDisabled, busy: busy, suppressFeedback: suppressFeedback, onPress: onSubmit, style: { flex: 1, alignSelf: 'auto' }, children: submitLabel })] })] });
|
|
40
|
+
if (stickyHeader && header)
|
|
41
|
+
return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: id('sticky-header'), header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, bodyStyle: { direction, gap: 16, paddingTop: 16 }, children: body });
|
|
42
|
+
return _jsxs(View, { testID: testID, style: { direction, padding: 16, gap: 16 }, children: [header, body] });
|
|
43
|
+
}
|
|
@@ -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';
|
|
@@ -60,7 +61,15 @@ export interface ProfileBlockProps {
|
|
|
60
61
|
sections: readonly ProfileSection[];
|
|
61
62
|
/** Host content under the sections on the block's inset, such as legal links. */
|
|
62
63
|
footer?: React.ReactNode;
|
|
64
|
+
/** Keeps the top bar (address and Close) pinned while the rest scrolls: the block becomes its own scroll view with the bar 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. */
|
|
65
|
+
stickyHeader?: boolean;
|
|
66
|
+
/** With `stickyHeader`: the bar's fill once content is under it. Defaults to the background role; in a sheet pass the sheet's fill. */
|
|
67
|
+
stickyHeaderBackground?: string;
|
|
68
|
+
/** The scroll view used with `stickyHeader`, such as a sheet library's own. Defaults to React Native's ScrollView. */
|
|
69
|
+
scrollComponent?: React.ComponentType<ScrollViewProps>;
|
|
70
|
+
/** `nativeID` of the name heading, so a sheet around the block can name itself with `accessibilityLabelledBy` (Android). */
|
|
71
|
+
headingId?: string;
|
|
63
72
|
testID?: string;
|
|
64
73
|
}
|
|
65
74
|
/** 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. */
|
|
66
|
-
export declare function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, testID }: ProfileBlockProps): React.JSX.Element;
|
|
75
|
+
export declare function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, stickyHeader, stickyHeaderBackground, scrollComponent, headingId, testID }: ProfileBlockProps): React.JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
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 React 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 { Button } from './button.js';
|
|
@@ -39,10 +40,14 @@ function ProfileListRow({ row }) {
|
|
|
39
40
|
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
41
|
}
|
|
41
42
|
/** 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 function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, testID }) {
|
|
43
|
+
export function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, stickyHeader, stickyHeaderBackground, scrollComponent, headingId, testID }) {
|
|
43
44
|
const colors = useColors(), fills = useFills(), t = useMessages(), { direction } = useHIG();
|
|
44
45
|
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) }));
|
|
45
46
|
const shown = sections.filter(section => section.rows.length > 0);
|
|
46
47
|
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
|
-
|
|
48
|
+
const bar = _jsxs(View, { testID: 'profile-bar', style: stickyHeader ? { direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', minHeight: 44 } : { 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 })] });
|
|
49
|
+
const body = _jsxs(_Fragment, { children: [_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', nativeID: headingId, 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] });
|
|
50
|
+
if (stickyHeader)
|
|
51
|
+
return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: 'profile-sticky-header', header: bar, background: stickyHeaderBackground, scrollComponent: scrollComponent, bodyStyle: { direction }, children: body });
|
|
52
|
+
return _jsxs(View, { testID: testID, style: { direction, padding: 16 }, children: [bar, body] });
|
|
48
53
|
}
|
|
@@ -45,7 +45,9 @@ export interface HIGProviderProps extends Partial<Omit<HIGContext, 'messages'>>
|
|
|
45
45
|
}
|
|
46
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. */
|
|
47
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;
|
|
48
|
-
export declare const useHIG: () => HIGContext
|
|
48
|
+
export declare const useHIG: () => HIGContext & {
|
|
49
|
+
provided?: boolean;
|
|
50
|
+
};
|
|
49
51
|
/** Number options with the nearest provider's `numberFormat` merged under them; only currency formats change. */
|
|
50
52
|
export declare function usePresentNumber(): <T extends Intl.NumberFormatOptions | undefined>(options: T) => T;
|
|
51
53
|
/** The locale numbers are formatted in: the nearest provider's `numberFormat.locale`, else its `locale`. */
|
|
@@ -65,4 +67,5 @@ export declare function useColorSpace(): HIGColorSpace;
|
|
|
65
67
|
export declare function useBrandColors(): Readonly<Record<HIGTableColorRole, string>>;
|
|
66
68
|
/** Complete built-in copy for the nearest HIGProvider: host translations over the English defaults. */
|
|
67
69
|
export declare function useMessages(): HIGMessages;
|
|
68
|
-
|
|
70
|
+
/** Controlled values never silently switch to internal state. `intent: null` commits without provider feedback. */
|
|
71
|
+
export declare function useControllable<T>(value: T | undefined, initial: T, onChange?: (value: T) => void, intent?: FeedbackIntent | null): [T, (next: T) => void];
|
package/native/dist/provider.js
CHANGED
|
@@ -16,8 +16,18 @@ 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
|
|
19
|
+
export function HIGProvider({ children, density, locale, direction, reducedMotion, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace, primaryColor, marketColors, messages, numberFormat }) {
|
|
20
20
|
const parent = useContext(Context);
|
|
21
|
+
density ??= parent.density;
|
|
22
|
+
locale ??= parent.locale;
|
|
23
|
+
direction ??= parent.direction;
|
|
24
|
+
onAccepted ??= parent.onAccepted;
|
|
25
|
+
feedback ??= parent.feedback;
|
|
26
|
+
fontFamily ??= parent.fontFamily;
|
|
27
|
+
fontFamilies ??= parent.fontFamilies;
|
|
28
|
+
monoFontFamily ??= parent.monoFontFamily;
|
|
29
|
+
maxFontSizeMultiplier ??= parent.maxFontSizeMultiplier;
|
|
30
|
+
letterSpacingByScript ??= parent.letterSpacingByScript;
|
|
21
31
|
const inherited = parent.messages;
|
|
22
32
|
const resolved = useMemo(() => resolveMessages(inherited, messages), [inherited, messages]);
|
|
23
33
|
const accent = primaryColor ?? parent.primaryColor;
|
|
@@ -31,7 +41,10 @@ export function HIGProvider({ children, density = 'comfortable', locale = 'en-US
|
|
|
31
41
|
const [osReduced, setOSReduced] = useState(false);
|
|
32
42
|
useEffect(() => { let alive = true; void AccessibilityInfo.isReduceMotionEnabled().then(v => { if (alive)
|
|
33
43
|
setOSReduced(v); }).catch(() => { }); const sub = AccessibilityInfo.addEventListener('reduceMotionChanged', setOSReduced); return () => { alive = false; sub.remove(); }; }, []);
|
|
34
|
-
|
|
44
|
+
const reduced = reducedMotion ?? (parent.provided ? parent.reducedMotion : osReduced), scripts = fontFamiliesByScript ?? parent.fontFamiliesByScript, format = numberFormat ?? parent.numberFormat;
|
|
45
|
+
// One context value for as long as nothing in it changes, so a provider that renders again re-renders no HIG Text or control below it.
|
|
46
|
+
const value = useMemo(() => ({ provided: true, density, locale, direction, reducedMotion: reduced, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript: scripts, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace: space, primaryColor: normalized, marketColors: inheritedMarket, messages: resolved, numberFormat: format }), [density, locale, direction, reduced, onAccepted, feedback, fontFamily, fontFamilies, scripts, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, space, normalized, inheritedMarket, resolved, format]);
|
|
47
|
+
return _jsx(Context.Provider, { value: value, children: _jsx(ColorsContext.Provider, { value: colors, children: children }) });
|
|
35
48
|
}
|
|
36
49
|
export const useHIG = () => useContext(Context);
|
|
37
50
|
/** Number options with the nearest provider's `numberFormat` merged under them; only currency formats change. */
|
|
@@ -51,21 +64,30 @@ export function useColorSpace() { return useContext(Context).colorSpace === 'dis
|
|
|
51
64
|
export function useBrandColors() { return colorTable(useContext(Context).colorSpace); }
|
|
52
65
|
/** Complete built-in copy for the nearest HIGProvider: host translations over the English defaults. */
|
|
53
66
|
export function useMessages() { const overrides = useContext(Context).messages; return useMemo(() => resolveMessages({ ...defaultMessages }, overrides), [overrides]); }
|
|
67
|
+
/** Controlled values never silently switch to internal state. `intent: null` commits without provider feedback. */
|
|
54
68
|
export function useControllable(value, initial, onChange, intent = 'selection') {
|
|
55
69
|
const [internal, setInternal] = useState(initial);
|
|
56
|
-
const
|
|
70
|
+
const controlled = useRef(value !== undefined).current, last = useRef(initial), warned = useRef(false);
|
|
71
|
+
if (controlled && value !== undefined)
|
|
72
|
+
last.current = value;
|
|
73
|
+
const current = controlled ? last.current : internal;
|
|
74
|
+
useEffect(() => { if ((value !== undefined) !== controlled && !warned.current) {
|
|
75
|
+
warned.current = true;
|
|
76
|
+
if (process.env.NODE_ENV !== 'production')
|
|
77
|
+
console.warn('HIG controlled state cannot change ownership after mount. Remount to reset it.');
|
|
78
|
+
} }, [controlled, value]);
|
|
57
79
|
const { feedback } = useHIG();
|
|
58
80
|
const id = useId();
|
|
59
81
|
const sequence = useRef(0);
|
|
60
82
|
const pending = useRef(null);
|
|
61
83
|
useEffect(() => { const request = pending.current; if (!request)
|
|
62
|
-
return; pending.current = null; if (Object.is(current, request.value)) {
|
|
84
|
+
return; pending.current = null; if (intent && Object.is(current, request.value)) {
|
|
63
85
|
try {
|
|
64
86
|
feedback?.emit({ id: `${id}/${++sequence.current}`, source: id, intent, origin: 'native' });
|
|
65
87
|
}
|
|
66
88
|
catch { /* Effects remain optional. */ }
|
|
67
89
|
} });
|
|
68
90
|
return [current, (next) => { if (Object.is(current, next))
|
|
69
|
-
return; pending.current = { value: next }; if (
|
|
91
|
+
return; pending.current = { value: next }; if (!controlled)
|
|
70
92
|
setInternal(next); onChange?.(next); }];
|
|
71
93
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import { type QRErrorCorrection } from '@bloxwap/hig/contracts/qr';
|
|
4
|
+
export type { QRErrorCorrection } from '@bloxwap/hig/contracts/qr';
|
|
5
|
+
export interface QRCodeProps {
|
|
6
|
+
/** The text to encode: an address, a payment URI, a link. Digits pack tightest, then upper-case alphanumerics, then UTF-8. A value too long for a QR code draws an empty square. */
|
|
7
|
+
value: string;
|
|
8
|
+
/** Edge of the square in dp, quiet zone included; default 196. */
|
|
9
|
+
size?: number;
|
|
10
|
+
/** Drawn over the centre, which is cleared of modules: an image URL, or a node such as a token mark laid out in the arena's box. */
|
|
11
|
+
arena?: React.ReactNode;
|
|
12
|
+
/** Error correction level. Defaults to `high` with an arena, which covers part of the code, and `medium` without. With an arena, `low` and `medium` are raised to `quartile` so the code still reads. */
|
|
13
|
+
errorCorrection?: QRErrorCorrection;
|
|
14
|
+
/** Colour of the modules. Defaults to the provider's `text` role. */
|
|
15
|
+
color?: string;
|
|
16
|
+
/** Colour of the tile behind the code. Defaults to the provider's `background` role; `'none'` draws no tile, for a code that sits on the host's own surface. */
|
|
17
|
+
background?: string;
|
|
18
|
+
/** Clear modules kept on every side, inside `size`; default 4, the margin scanners expect. Pass 0 only where the host keeps that margin itself. */
|
|
19
|
+
quietZone?: number;
|
|
20
|
+
/** Accessible name. Defaults to the built-in “QR code”. */
|
|
21
|
+
label?: string;
|
|
22
|
+
/** Hides the code from assistive technology, for a host that names it on an element of its own. */
|
|
23
|
+
decorative?: boolean;
|
|
24
|
+
/** Also the prefix of `-code` (the drawing) and `-arena` (the image or node in the centre). */
|
|
25
|
+
testID?: string;
|
|
26
|
+
style?: StyleProp<ViewStyle>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A QR code in the Cuer style: round modules, rounded finder patterns and an optional arena in the centre. HIG encodes the
|
|
30
|
+
* value itself; the drawing is one `react-native-svg` path, so the only peer is `react-native-svg`. The value is encoded once
|
|
31
|
+
* per `value`, `errorCorrection` and arena; `size`, the colours and the quiet zone only change props of the drawing.
|
|
32
|
+
*/
|
|
33
|
+
export declare function QRCode({ value, size, arena, errorCorrection, color, background, quietZone, label, decorative, testID, style }: QRCodeProps): React.JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { Image, StyleSheet, View } from 'react-native';
|
|
4
|
+
import Svg, { Path, Rect } from 'react-native-svg';
|
|
5
|
+
import { QR_QUIET_ZONE, qrCodeGeometry, qrFrame } from '@bloxwap/hig/contracts/qr';
|
|
6
|
+
import { useColors, useMessages } from './provider.js';
|
|
7
|
+
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
8
|
+
const drawn = (node) => node != null && node !== false && node !== true && node !== '';
|
|
9
|
+
// Centred rather than offset from an edge, so a right-to-left layout cannot move the arena off the cleared square.
|
|
10
|
+
const styles = StyleSheet.create({ centre: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0, alignItems: 'center', justifyContent: 'center' }, arena: { overflow: 'hidden', alignItems: 'center', justifyContent: 'center' } });
|
|
11
|
+
/**
|
|
12
|
+
* A QR code in the Cuer style: round modules, rounded finder patterns and an optional arena in the centre. HIG encodes the
|
|
13
|
+
* value itself; the drawing is one `react-native-svg` path, so the only peer is `react-native-svg`. The value is encoded once
|
|
14
|
+
* per `value`, `errorCorrection` and arena; `size`, the colours and the quiet zone only change props of the drawing.
|
|
15
|
+
*/
|
|
16
|
+
export function QRCode({ value, size = 196, arena, errorCorrection, color, background, quietZone = QR_QUIET_ZONE, label, decorative = false, testID, style }) {
|
|
17
|
+
const colors = useColors();
|
|
18
|
+
const t = useMessages();
|
|
19
|
+
const withArena = drawn(arena);
|
|
20
|
+
const geometry = useMemo(() => qrCodeGeometry(value, { errorCorrection, arena: withArena }), [value, errorCorrection, withArena]);
|
|
21
|
+
const frame = useMemo(() => geometry ? qrFrame(geometry, size, quietZone) : null, [geometry, size, quietZone]);
|
|
22
|
+
const tile = background === 'none' || background === 'transparent' ? null : background ?? colors.background;
|
|
23
|
+
const named = !decorative && geometry !== null;
|
|
24
|
+
const box = frame?.arena;
|
|
25
|
+
const access = named ? { accessible: true, accessibilityRole: 'image', accessibilityLabel: label ?? t.qrCode } : hidden;
|
|
26
|
+
const codeID = testID ? `${testID}-code` : undefined, arenaID = testID ? `${testID}-arena` : undefined;
|
|
27
|
+
const boxStyle = box ? { width: box.edge, height: box.edge, borderRadius: box.corner } : undefined;
|
|
28
|
+
return _jsxs(View, { ...access, testID: testID, style: [{ width: size, height: size }, style], children: [_jsxs(Svg, { width: size, height: size, viewBox: frame?.viewBox, accessible: false, testID: codeID, children: [tile && frame ? _jsx(Rect, { x: -frame.quietZone, y: -frame.quietZone, width: frame.span, height: frame.span, rx: frame.tileRadius, fill: tile }) : null, geometry ? _jsx(Path, { d: geometry.path, fill: color ?? colors.text }) : null] }), box ? _jsx(View, { ...hidden, pointerEvents: 'none', style: styles.centre, children: typeof arena === 'string' ? _jsx(Image, { source: { uri: arena }, testID: arenaID, style: boxStyle }) : _jsx(View, { testID: arenaID, style: [styles.arena, boxStyle], children: arena }) }) : null] });
|
|
29
|
+
}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type ScrollViewProps } from 'react-native';
|
|
3
|
-
import type { ChoicesProps } from './selection-types.js';
|
|
3
|
+
import type { Choice, ChoicesProps } from './selection-types.js';
|
|
4
|
+
import type { ScreenHeaderControlProps } from './screen-header.js';
|
|
4
5
|
export declare function RadioGroup({ label, options, value, defaultValue, disabled, onValueChange }: ChoicesProps): React.JSX.Element;
|
|
5
6
|
/** 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). */
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
/** One segment. `testID` is the segment's test ID, in place of `<group testID>-<value>`. */
|
|
8
|
+
export interface SegmentedControlOption extends Choice {
|
|
8
9
|
testID?: string;
|
|
9
10
|
}
|
|
10
|
-
export
|
|
11
|
+
export interface SegmentedControlProps extends Omit<ChoicesProps, 'options'> {
|
|
12
|
+
options: readonly SegmentedControlOption[]; /** Keeps `label` as the group's accessible name but does not draw it, for a control whose heading or row already names it. */
|
|
13
|
+
hideLabel?: boolean; /** Test ID of the group; each segment takes `<testID>-<value>`, such as `trade-share-mode-video`, unless the option sets its own `testID`. */
|
|
14
|
+
testID?: string; /** Pressable props for every segment, such as `{android_disableSound: true}` when the host plays its own sound. HIG keeps its own name, role, state, target and press. */
|
|
15
|
+
segmentProps?: ScreenHeaderControlProps;
|
|
16
|
+
}
|
|
17
|
+
export declare function SegmentedControl({ label, options, value, defaultValue, disabled, hideLabel, testID, segmentProps, onValueChange }: SegmentedControlProps): React.JSX.Element;
|
|
11
18
|
export interface FilterOption {
|
|
12
19
|
value: string;
|
|
13
20
|
label: string;
|
|
@@ -21,7 +28,12 @@ export interface FilterProps {
|
|
|
21
28
|
defaultValue?: string;
|
|
22
29
|
disabled?: boolean;
|
|
23
30
|
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>;
|
|
31
|
+
scrollComponent?: React.ComponentType<ScrollViewProps>; /** Units the row scrolls out past its container on each side, so the capsules are cut by the container's edge, while the first and last capsule rest this far in: pass the container's side padding. Default 0. */
|
|
32
|
+
bleed?: number;
|
|
25
33
|
}
|
|
26
|
-
/**
|
|
27
|
-
|
|
34
|
+
/**
|
|
35
|
+
* A horizontal, scrolling row of single-choice filter chips. The selected chip inverts and its circle shows a check that animates in.
|
|
36
|
+
* The row scrolls the selected chip fully into view on mount and whenever the selection changes, through the scroll view's
|
|
37
|
+
* `scrollTo` (a host `scrollComponent` receives the ref and `onLayout`/`onScroll`; one without `scrollTo` simply does not scroll).
|
|
38
|
+
*/
|
|
39
|
+
export declare function Filter({ label, options, value, defaultValue, disabled, onValueChange, scrollComponent, bleed }: FilterProps): React.JSX.Element;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { createElement as _createElement } from "react";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Check } from '@bloxwap/icons/native/check';
|
|
4
|
+
import { assertUniqueKeys } from '@bloxwap/hig/contracts';
|
|
2
5
|
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
3
6
|
import { Animated, Easing, Image, Platform, Pressable, ScrollView, View } from 'react-native';
|
|
4
7
|
import { tokens } from '@bloxwap/hig/tokens';
|
|
5
8
|
import { useControllable, useColors, useFills, useHIG } from './provider.js';
|
|
6
9
|
import { Text } from './surface.js';
|
|
7
10
|
export function RadioGroup({ label, options, value, defaultValue = '', disabled, onValueChange }) {
|
|
11
|
+
assertUniqueKeys(options, option => option.value, 'Choices');
|
|
8
12
|
const [current, set] = useControllable(value, defaultValue, onValueChange);
|
|
9
13
|
const { direction, locale } = useHIG();
|
|
10
14
|
const colors = useColors();
|
|
@@ -16,9 +20,10 @@ export function RadioGroup({ label, options, value, defaultValue = '', disabled,
|
|
|
16
20
|
activate(); }, style: { minHeight: 48, paddingVertical: 12, flexDirection: 'row', alignItems: 'center', gap: 12, opacity: blocked ? 0.5 : 1 }, children: [_jsx(Text, { accessible: false, children: current === o.value ? '●' : '○' }), _jsxs(View, { style: { flex: 1 }, children: [_jsx(Text, { accessible: false, accessibilityLanguage: o.lang, children: o.label }), o.description !== undefined && _jsx(Text, { accessible: false, accessibilityLanguage: locale, style: { color: colors.muted, fontSize: 14, lineHeight: 20 }, children: o.description })] })] }, o.value);
|
|
17
21
|
})] });
|
|
18
22
|
}
|
|
19
|
-
/** Segments are 36dp inside a 44dp track; the slop restores a 48dp touch target. */
|
|
20
|
-
const segmentSlop = { top: 6, bottom: 6 };
|
|
21
|
-
export function SegmentedControl({ label, options, value, defaultValue = '', disabled, hideLabel, testID, onValueChange }) {
|
|
23
|
+
/** Segments are 36dp inside a 44dp track (28 in a 36 track at compact density); the slop restores a 48dp touch target at either density. Segments sit 4 apart and the slop is vertical only, so neighbouring targets never overlap. Android (Fabric) counts a child's hitSlop in its parent's overflow inset, so the slop past the track is reachable there too. */
|
|
24
|
+
const segmentSlop = { top: 6, bottom: 6 }, compactSegmentSlop = { top: 10, bottom: 10 };
|
|
25
|
+
export function SegmentedControl({ label, options, value, defaultValue = '', disabled, hideLabel, testID, segmentProps, onValueChange }) {
|
|
26
|
+
assertUniqueKeys(options, option => option.value, 'Choices');
|
|
22
27
|
const [current, set] = useControllable(value, defaultValue, onValueChange);
|
|
23
28
|
const { direction, locale, reducedMotion, density } = useHIG();
|
|
24
29
|
const colors = useColors();
|
|
@@ -50,15 +55,17 @@ export function SegmentedControl({ label, options, value, defaultValue = '', dis
|
|
|
50
55
|
const checked = current === option.value, blocked = !!disabled || !!option.disabled;
|
|
51
56
|
const activate = () => { if (!blocked)
|
|
52
57
|
set(option.value); };
|
|
53
|
-
return
|
|
54
|
-
activate(); }, hitSlop: segmentSlop, style: { flex: 1, minWidth: 0, minHeight: compact ? 28 : 36, paddingHorizontal: 12, paddingVertical: compact ? 2 : 4, alignItems: 'stretch', justifyContent: 'center', borderRadius: 9999, opacity: blocked ? 0.5 : 1 }
|
|
58
|
+
return _createElement(Pressable, { ...segmentProps, key: option.value, testID: option.testID ?? (testID === undefined ? undefined : `${testID}-${option.value}`), accessible: true, accessibilityRole: 'radio', accessibilityLabel: option.label, accessibilityHint: option.description, accessibilityLanguage: option.lang, "aria-checked": checked, "aria-disabled": blocked, accessibilityState: { checked, disabled: blocked }, accessibilityActions: [{ name: 'activate' }], disabled: blocked, onPress: activate, onAccessibilityAction: event => { if (event.nativeEvent.actionName === 'activate')
|
|
59
|
+
activate(); }, hitSlop: compact ? compactSegmentSlop : segmentSlop, style: { flex: 1, minWidth: 0, minHeight: compact ? 28 : 36, paddingHorizontal: 12, paddingVertical: compact ? 2 : 4, alignItems: 'stretch', justifyContent: 'center', borderRadius: 9999, opacity: blocked ? 0.5 : 1 } },
|
|
60
|
+
_jsx(Text, { accessible: false, accessibilityLanguage: option.lang, style: { color: checked ? colors.text : colors.muted, fontWeight: '500', textAlign: 'center' }, children: option.label }),
|
|
61
|
+
option.description !== undefined && _jsx(Text, { accessible: false, accessibilityLanguage: locale, style: { color: colors.muted, fontSize: 14, lineHeight: 20, textAlign: 'center' }, children: option.description }));
|
|
55
62
|
})] }) })] });
|
|
56
63
|
}
|
|
57
64
|
/** Chips are 40dp; the slop restores a 44dp touch target. */
|
|
58
65
|
const filterSlop = { top: 2, bottom: 2 };
|
|
59
66
|
const hiddenMark = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', pointerEvents: 'none' };
|
|
60
67
|
/** One chip. Its circle holds the option's icon or an empty ring; when the chip is selected the circle fills and a check settles in, and deselecting reverses it. */
|
|
61
|
-
function FilterChip({ option, checked, blocked, reducedMotion, onSelect }) {
|
|
68
|
+
function FilterChip({ option, checked, blocked, reducedMotion, onSelect, onLayout }) {
|
|
62
69
|
const colors = useColors();
|
|
63
70
|
const fills = useFills();
|
|
64
71
|
const progress = useRef(new Animated.Value(checked ? 1 : 0)).current;
|
|
@@ -80,11 +87,33 @@ function FilterChip({ option, checked, blocked, reducedMotion, onSelect }) {
|
|
|
80
87
|
const activate = () => { if (!blocked)
|
|
81
88
|
onSelect(); };
|
|
82
89
|
return _jsxs(Pressable, { accessible: true, accessibilityRole: 'radio', accessibilityLabel: option.label, "aria-checked": checked, "aria-disabled": blocked, accessibilityState: { checked, disabled: blocked }, accessibilityActions: [{ name: 'activate' }], disabled: blocked, onPress: activate, onAccessibilityAction: event => { if (event.nativeEvent.actionName === 'activate')
|
|
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(
|
|
90
|
+
activate(); }, hitSlop: filterSlop, onLayout: onLayout, 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(Check, { size: 16, color: colors.text }) })] }), _jsx(Text, { accessible: false, style: { fontSize: 14, lineHeight: 21, fontWeight: '600', color: ink }, children: option.label })] });
|
|
84
91
|
}
|
|
85
|
-
/**
|
|
86
|
-
|
|
92
|
+
/**
|
|
93
|
+
* A horizontal, scrolling row of single-choice filter chips. The selected chip inverts and its circle shows a check that animates in.
|
|
94
|
+
* The row scrolls the selected chip fully into view on mount and whenever the selection changes, through the scroll view's
|
|
95
|
+
* `scrollTo` (a host `scrollComponent` receives the ref and `onLayout`/`onScroll`; one without `scrollTo` simply does not scroll).
|
|
96
|
+
*/
|
|
97
|
+
export function Filter({ label, options, value, defaultValue = '', disabled, onValueChange, scrollComponent = ScrollView, bleed = 0 }) {
|
|
98
|
+
assertUniqueKeys(options, option => option.value, 'Choices');
|
|
87
99
|
const [current, set] = useControllable(value, defaultValue, onValueChange);
|
|
88
100
|
const { direction, reducedMotion } = useHIG();
|
|
89
|
-
|
|
101
|
+
const Scroll = scrollComponent;
|
|
102
|
+
const scroller = useRef(null), chips = useRef(new Map()), viewport = useRef({ width: 0, offset: 0 }), mounted = useRef(false);
|
|
103
|
+
// Left-to-right only: right-to-left horizontal offsets differ by platform, so that row stays where the reader leaves it.
|
|
104
|
+
const reveal = (animated) => {
|
|
105
|
+
const chip = chips.current.get(current), { width, offset } = viewport.current;
|
|
106
|
+
if (!chip || width <= 0 || direction === 'rtl')
|
|
107
|
+
return;
|
|
108
|
+
// With a bleed the chip's x includes the leading inset, and a revealed chip keeps the inset clear on either side.
|
|
109
|
+
const x = chip.x - bleed < offset ? chip.x - bleed : chip.x + chip.width + bleed > offset + width ? chip.x + chip.width + bleed - width : null;
|
|
110
|
+
if (x === null)
|
|
111
|
+
return;
|
|
112
|
+
viewport.current.offset = Math.max(0, x);
|
|
113
|
+
scroller.current?.scrollTo?.({ x: viewport.current.offset, animated: animated && !reducedMotion });
|
|
114
|
+
};
|
|
115
|
+
useEffect(() => { if (mounted.current)
|
|
116
|
+
reveal(true); mounted.current = true; }, [current]);
|
|
117
|
+
return _jsx(Scroll, { ref: scroller, horizontal: true, showsHorizontalScrollIndicator: false, keyboardShouldPersistTaps: 'handled', accessibilityRole: 'radiogroup', accessibilityLabel: label, style: { flexGrow: 0, direction, ...(bleed ? { marginHorizontal: -bleed } : null) }, contentContainerStyle: { direction, gap: 8, ...(bleed ? { paddingHorizontal: bleed } : null) }, onLayout: event => { viewport.current.width = event.nativeEvent.layout.width; reveal(false); }, onScroll: event => { viewport.current.offset = event.nativeEvent.contentOffset.x; }, scrollEventThrottle: 16, children: options.map(option => _jsx(FilterChip, { option: option, checked: current === option.value, blocked: !!disabled || !!option.disabled, reducedMotion: !!reducedMotion, onSelect: () => set(option.value), onLayout: event => { const { x, width } = event.nativeEvent.layout; chips.current.set(option.value, { x, width }); if (option.value === current)
|
|
118
|
+
reveal(false); } }, option.value)) });
|
|
90
119
|
}
|
|
@@ -11,14 +11,16 @@ export interface RewardPromo {
|
|
|
11
11
|
label: string;
|
|
12
12
|
onSelect: () => void;
|
|
13
13
|
};
|
|
14
|
-
/** The headline figure: the pool so far, or the top prize. `null` reads as unknown. */
|
|
15
|
-
amount
|
|
16
|
-
/**
|
|
14
|
+
/** The headline figure: the pool so far, or the top prize. A number updates place by place, formatted with `amountOptions`; `null` reads as unknown; a string is host text drawn as given in the same style, such as `$500` already formatted. Leave it out (with no `figure`) for a promotion with no figure. */
|
|
15
|
+
amount?: number | null | string;
|
|
16
|
+
/** Host content drawn in the headline figure's place (`<testID>-figure`), in place of `amount`, such as the host's own live figure. It is drawn as given and reads itself. */
|
|
17
|
+
figure?: React.ReactNode;
|
|
18
|
+
/** Format of a number `amount` and of `goal`. Defaults to whole US dollars. */
|
|
17
19
|
amountOptions?: Intl.NumberFormatOptions;
|
|
18
|
-
/** The amount the pool is filling towards. Draws the progress bar under the caption. */
|
|
20
|
+
/** The amount the pool is filling towards. Draws the progress bar under the caption (full only against a number `amount`). */
|
|
19
21
|
goal?: number;
|
|
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. */
|
|
21
|
-
caption?:
|
|
22
|
+
/** The line under the figure. A function receives the formatted goal: `goal => 'of ' + goal + ' prize pool'`. A string is drawn as given and read with the figure: top prize. Any other node, such as a live countdown, is drawn as given after the figure and reads itself. */
|
|
23
|
+
caption?: React.ReactNode | ((goal: string) => React.ReactNode);
|
|
22
24
|
/** 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
25
|
headline?: React.ReactNode;
|
|
24
26
|
/** Continues the sentence after the headline in the muted colour: Funded by builder fees on every trade. */
|
|
@@ -102,7 +104,8 @@ export interface RewardBlockProps {
|
|
|
102
104
|
listTitle?: string;
|
|
103
105
|
/** The column heading over the scores: Entries. */
|
|
104
106
|
scoreTitle?: string;
|
|
105
|
-
|
|
107
|
+
/** The standings, in order. Leave them out for a promotion-only pane: no list is drawn. */
|
|
108
|
+
entries?: readonly RewardEntry[];
|
|
106
109
|
/** Format of every score. Defaults to a whole number. An entry's own `scoreOptions` wins. */
|
|
107
110
|
scoreOptions?: Intl.NumberFormatOptions;
|
|
108
111
|
/** Words for the verified mark, read after the name. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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
|
-
import { formatNumber } from '
|
|
3
|
+
import { formatNumber } from './number-format.js';
|
|
4
4
|
import { withAlpha } from '@bloxwap/hig/tokens';
|
|
5
5
|
import { useColors, useFills, useHIG, useNumberLocale, usePresentNumber } from './provider.js';
|
|
6
6
|
import { Surface, Text } from './surface.js';
|
|
@@ -14,6 +14,7 @@ import { StickyHeaderLayout } from './sticky-header.js';
|
|
|
14
14
|
import { figureProps } from './figure.js';
|
|
15
15
|
const wholeDollars = { style: 'currency', currency: 'USD', maximumFractionDigits: 0 };
|
|
16
16
|
const whole = { maximumFractionDigits: 0 };
|
|
17
|
+
const noEntries = [];
|
|
17
18
|
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
18
19
|
const avatar = 40, space = ' ';
|
|
19
20
|
/** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
|
|
@@ -21,12 +22,16 @@ export function rewardProgress(amount, goal) {
|
|
|
21
22
|
return amount == null || goal == null || !Number.isFinite(amount) || !Number.isFinite(goal) || !(goal > 0) ? null : Math.min(1, Math.max(0, amount / goal));
|
|
22
23
|
}
|
|
23
24
|
/** 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. */
|
|
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
|
+
export function RewardBlock({ title, promo, tabs, you, youLabel, status, listTitle, scoreTitle, entries = noEntries, scoreOptions = whole, verifiedLabel, verifiedMark, verifiedMarkInteractive, loading, loadingLabel, pagination, footnote, onBack, headerAction, stickyHeader, stickyHeaderBackground, scrollComponent, header: showHeader = true, testID }) {
|
|
25
26
|
const colors = useColors(), fills = useFills(), { direction, monoFontFamily } = useHIG(), locale = useNumberLocale(), present = usePresentNumber();
|
|
26
27
|
const prefix = testID ?? 'reward', tid = (part) => `${prefix}-${part}`;
|
|
27
|
-
const money = promo?.amountOptions ?? wholeDollars, reached = promo ? rewardProgress(
|
|
28
|
+
const amount = promo?.amount, money = promo?.amountOptions ?? wholeDollars, reached = promo ? rewardProgress(typeof amount === 'string' ? null : amount, promo.goal) : null;
|
|
28
29
|
const caption = typeof promo?.caption === 'function' ? promo.goal !== undefined ? promo.caption(formatNumber(promo.goal, locale, present(money))) : undefined : promo?.caption;
|
|
30
|
+
// A text caption is read with the figure; a host node (such as a live countdown) and a host figure read themselves.
|
|
31
|
+
const captionText = typeof caption === 'string' || typeof caption === 'number' ? String(caption) : null, captionNode = captionText === null && caption != null && caption !== false ? caption : null;
|
|
32
|
+
const hostFigure = promo?.figure != null && promo.figure !== false ? promo.figure : null;
|
|
29
33
|
const caps = { fontFamily: monoFontFamily, fontSize: 12, lineHeight: 16, letterSpacing: 1.5, textTransform: 'uppercase' };
|
|
34
|
+
const figureStyle = { fontSize: 44, lineHeight: 50, fontWeight: '700', letterSpacing: -0.9 }, captionStyle = { fontFamily: monoFontFamily, fontSize: 15, lineHeight: 22, color: colors.muted };
|
|
30
35
|
const standing = (entry, id, style, lead) => {
|
|
31
36
|
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
37
|
const said = figure ? formatNumberReadout(figure.value, locale, present(figure.options), figure.formattedValue, figure.prefix, figure.suffix).text : detail;
|
|
@@ -44,7 +49,7 @@ export function RewardBlock({ title, promo, tabs, you, youLabel, status, listTit
|
|
|
44
49
|
const small = { fontSize: 14, lineHeight: 21, color: colors.muted };
|
|
45
50
|
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
51
|
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(
|
|
52
|
+
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] }), hostFigure ? _jsxs(View, { testID: tid('amount'), style: { gap: 4 }, children: [_jsx(View, { testID: tid('figure'), style: { alignItems: 'flex-start' }, children: hostFigure }), captionText ? _jsx(Text, { testID: tid('caption'), style: captionStyle, children: captionText }) : null] }) : amount !== undefined || captionText ? _jsxs(View, { testID: tid('amount'), accessible: true, accessibilityLabel: [amount === undefined ? null : typeof amount === 'string' ? amount : formatNumberReadout(amount, locale, present(money)).text, captionText].filter(Boolean).join(' '), style: { gap: 4 }, children: [amount === undefined ? null : _jsx(View, { ...hidden, style: { alignItems: 'flex-start' }, children: typeof amount === 'string' ? _jsx(Text, { style: { ...figureStyle, color: colors.positive }, children: amount }) : _jsx(AnimatedNumberReadout, { value: amount, options: money, tone: 'positive', style: figureStyle }) }), captionText ? _jsx(Text, { ...hidden, testID: tid('caption'), style: captionStyle, children: captionText }) : null] }) : null, captionNode ? _jsx(View, { testID: tid('caption'), style: { marginTop: -8 }, children: captionNode }) : 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
53
|
if (!showHeader)
|
|
49
54
|
return _jsx(View, { testID: testID, style: { padding: 16, paddingTop: 0 }, children: body });
|
|
50
55
|
if (stickyHeader)
|
|
@@ -23,27 +23,37 @@ export interface ScreenHeaderProps {
|
|
|
23
23
|
titleRef?: React.Ref<React.ComponentRef<typeof View>>;
|
|
24
24
|
/** Short host text in a badge beside the title, read as part of the heading after a pause: Demo. */
|
|
25
25
|
badge?: string;
|
|
26
|
+
/** A kicker over the title, centred in small muted capitals: Builder fee. Host text, read before the heading as its own element (test ID `<testID>-eyebrow`). The header grows to fit it. */
|
|
27
|
+
eyebrow?: string;
|
|
26
28
|
/** Hides the title visually while it stays the accessible heading, for a host that draws its own visible title and must not have it read twice. The header keeps its height. */
|
|
27
29
|
hideTitle?: boolean;
|
|
30
|
+
/** Host text that describes the pane, never drawn and read after the heading as its accessibility hint, such as a sheet's description. */
|
|
31
|
+
description?: string;
|
|
28
32
|
/** Marks the header as pinned in the host's scroller: it is transparent at rest and takes `stickyHeaderBackground` once `scrolled` is true. Get `scrolled` from `useStickyHeaderScroll()` on that scroller. */
|
|
29
33
|
stickyHeader?: boolean;
|
|
30
34
|
/** With `stickyHeader`: content has scrolled under the header, so it draws its fill. */
|
|
31
35
|
scrolled?: boolean;
|
|
32
36
|
/** With `stickyHeader`: the fill once content is under the header. Defaults to the background role; in a sheet pass the sheet's fill (`useColors().overlay`). */
|
|
33
37
|
stickyHeaderBackground?: string;
|
|
34
|
-
/**
|
|
38
|
+
/** With `stickyHeader`: space kept inside the fill above the row and to each side of it, such as the blocks' 16, so the inset fills with the header once content scrolls under it. Pass the inset here, not as `style` padding: React Native moves a sticky child's `style` onto its own wrapper, outside the fill. */
|
|
39
|
+
inset?: number;
|
|
40
|
+
/** Style of the header's container. With `stickyHeader` it sits outside the fill (React Native moves it onto the sticky slot's wrapper once pinned); put an inset in `inset`. */
|
|
35
41
|
style?: StyleProp<ViewStyle>;
|
|
36
42
|
}
|
|
43
|
+
/** Pressable props for a header Close: those of `ScreenHeaderControlProps`, plus `disabled`, which draws Close unavailable (a faint glyph, read as disabled, not pressable), for example while the pane's action is being signed. */
|
|
44
|
+
export type HeaderCloseProps = ScreenHeaderControlProps & {
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
};
|
|
37
47
|
/** The block header's Close control, shared by the blocks that draw one. */
|
|
38
48
|
export declare function HeaderClose({ onClose, label, testID, closeProps }: {
|
|
39
49
|
onClose: () => void;
|
|
40
50
|
label: string;
|
|
41
51
|
testID?: string;
|
|
42
|
-
closeProps?:
|
|
52
|
+
closeProps?: HeaderCloseProps;
|
|
43
53
|
}): React.JSX.Element;
|
|
44
54
|
/**
|
|
45
55
|
* The header of a block that is its own screen: Back on the leading edge, the title centred, an optional control on the trailing
|
|
46
56
|
* edge. The settings blocks (Notifications, Signals, Sound & Haptics) draw it; the other native blocks draw a header that matches
|
|
47
57
|
* it. Import it from `@bloxwap/hig/native/screen-header` for a host pane that has no block.
|
|
48
58
|
*/
|
|
49
|
-
export declare function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, hideTitle, stickyHeader, scrolled, stickyHeaderBackground, style }: ScreenHeaderProps): React.JSX.Element;
|
|
59
|
+
export declare function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, eyebrow, hideTitle, description, stickyHeader, scrolled, stickyHeaderBackground, inset, style }: ScreenHeaderProps): React.JSX.Element;
|