@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
|
@@ -10,20 +10,28 @@ export { ChevronIcon } from './icons.js';
|
|
|
10
10
|
export { useStickyHeaderScroll } from './sticky-header.js';
|
|
11
11
|
/** The block header's Close control, shared by the blocks that draw one. */
|
|
12
12
|
export function HeaderClose({ onClose, label, testID, closeProps }) {
|
|
13
|
-
const colors = useColors();
|
|
14
|
-
return _jsx(IconButton, { ...closeProps, intent: 'ghost', label: label, suppressFeedback: true, testID: testID, onPress: onClose, children: _jsx(CloseIcon, { color: colors.text }) });
|
|
13
|
+
const colors = useColors(), off = !!closeProps?.disabled;
|
|
14
|
+
return _jsx(IconButton, { ...closeProps, disabled: off, intent: 'ghost', label: label, suppressFeedback: true, testID: testID, onPress: onClose, children: _jsx(CloseIcon, { color: off ? colors.faint : colors.text }) });
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* The header of a block that is its own screen: Back on the leading edge, the title centred, an optional control on the trailing
|
|
18
18
|
* edge. The settings blocks (Notifications, Signals, Sound & Haptics) draw it; the other native blocks draw a header that matches
|
|
19
19
|
* it. Import it from `@bloxwap/hig/native/screen-header` for a host pane that has no block.
|
|
20
20
|
*/
|
|
21
|
-
export function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, hideTitle, stickyHeader, scrolled, stickyHeaderBackground, style }) {
|
|
21
|
+
export function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, eyebrow, hideTitle, description, stickyHeader, scrolled, stickyHeaderBackground, inset, style }) {
|
|
22
22
|
const colors = useColors(), t = useMessages(), { direction } = useHIG();
|
|
23
23
|
const id = (part) => testID === undefined ? undefined : `${testID}-${part}`;
|
|
24
24
|
// Clear white stays in the accessibility tree where opacity 0 might not; the title keeps its line so the header keeps its height.
|
|
25
25
|
const ink = hideTitle ? '#ffffff00' : colors.text;
|
|
26
26
|
const heading = { textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: ink };
|
|
27
27
|
const fill = stickyHeader ? stickyHeaderFill(!!scrolled, stickyHeaderBackground ?? colors.background) : undefined;
|
|
28
|
-
|
|
28
|
+
const pad = stickyHeader && inset ? inset : 0, height = 44 + pad;
|
|
29
|
+
// Beside the sides the title fills the middle; under an eyebrow it sits in a column at its own height.
|
|
30
|
+
const grow = eyebrow ? null : { flex: 1 };
|
|
31
|
+
const titleNode = badge ? _jsxs(View, { ref: titleRef, nativeID: headingId, accessible: true, accessibilityRole: 'header', accessibilityLabel: `${title}, ${badge}`, accessibilityHint: description, style: { ...grow, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8, minWidth: 0 }, children: [_jsx(Text, { testID: id('title'), accessible: false, numberOfLines: 1, style: { ...heading, flexShrink: 1 }, children: title }), hideTitle ? null : _jsx(View, { testID: id('badge'), style: { flexShrink: 0 }, children: _jsx(Badge, { children: _jsx(Text, { style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.text }, children: badge }) }) })] }) : _jsx(Text, { ref: titleRef, testID: id('title'), nativeID: headingId, accessibilityRole: 'header', accessibilityHint: description, numberOfLines: 1, style: { ...grow, ...heading }, children: title });
|
|
32
|
+
const row = _jsxs(View, { testID: id('header'), style: [{ flexDirection: 'row', alignItems: 'center', minHeight: height }, pad ? { paddingTop: pad, paddingHorizontal: pad } : undefined, fill, stickyHeader ? undefined : style], children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onBack ? _jsx(IconButton, { ...backProps, intent: 'ghost', label: t.back, disabled: backDisabled, suppressFeedback: true, testID: id('back'), onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: backDisabled ? colors.faint : colors.text }) }) }) : null }), eyebrow ? _jsxs(View, { style: { flex: 1, minWidth: 0, gap: 2 }, children: [_jsx(Text, { testID: id('eyebrow'), numberOfLines: 1, style: { textAlign: 'center', fontSize: 12, lineHeight: 16, letterSpacing: 1.5, textTransform: 'uppercase', color: colors.muted }, children: eyebrow }), titleNode] }) : titleNode, _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: action })] });
|
|
33
|
+
// A pinned header is the host scroller's sticky child: React Native moves its `style` prop onto the slot's own wrapper and passes flex:1 in its
|
|
34
|
+
// place, which in that column measures the child at its minimum height alone (0 plus padding). So the outer view carries only what may move
|
|
35
|
+
// (the host's style) and a minimum height of the whole row, and the row, the inset and the fill sit on the inner view, pinned or not.
|
|
36
|
+
return stickyHeader ? _jsx(View, { style: [{ minHeight: height }, style], children: row }) : row;
|
|
29
37
|
}
|
package/native/dist/select.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { assertUniqueKeys } from '@bloxwap/hig/contracts';
|
|
3
|
+
import { useState, useRef, useEffect } from 'react';
|
|
3
4
|
import { View } from 'react-native';
|
|
4
5
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
6
|
import { useControllable, useHIG } from './provider.js';
|
|
6
7
|
import { Button } from './button.js';
|
|
7
8
|
import { Dialog } from './overlay.js';
|
|
8
9
|
import { RadioGroup } from './radio-group.js';
|
|
9
|
-
export function Select(props) { const { messages } = useHIG(); const [open, setOpen] = useState(false); const trigger = useRef(null);
|
|
10
|
+
export function Select(props) { const { messages } = useHIG(); const [open, setOpen] = useState(false); const trigger = useRef(null); assertUniqueKeys(props.options, o => o.value, 'Select'); const controlled = useRef(props.value !== undefined).current; const [stored, set] = useControllable(props.value, props.defaultValue ?? props.options.find(o => !o.disabled)?.value ?? '', props.onValueChange); const current = props.options.some(o => o.value === stored && !o.disabled) ? stored : controlled ? '' : props.options.find(o => !o.disabled)?.value ?? ''; useEffect(() => { if (!controlled && stored !== current)
|
|
11
|
+
set(current); }, [controlled, stored, current]); return _jsxs(View, { children: [_jsxs(Button, { ref: trigger, disabled: props.disabled, intent: 'secondary', onPress: () => setOpen(true), children: [props.label, ": ", props.options.find(o => o.value === current)?.label ?? messages.choose ?? en.choose] }), _jsx(Dialog, { title: props.label, description: messages.chooseOne ?? en.chooseOne, open: open, onOpenChange: setOpen, returnFocusRef: trigger, children: _jsx(RadioGroup, { ...props, value: current, onValueChange: v => { set(v); setOpen(false); } }) })] }); }
|
|
@@ -4,5 +4,6 @@ export { Checkbox } from './checkbox.js';
|
|
|
4
4
|
export { RadioGroup } from './radio-group.js';
|
|
5
5
|
export { Select } from './select.js';
|
|
6
6
|
export { Slider } from './slider.js';
|
|
7
|
-
export { SegmentedControl, type SegmentedControlProps } from './radio-group.js';
|
|
7
|
+
export { SegmentedControl, type SegmentedControlProps, type SegmentedControlOption } from './radio-group.js';
|
|
8
8
|
export { Filter, type FilterOption, type FilterProps } from './radio-group.js';
|
|
9
|
+
export { PresetGroup, type PresetGroupProps, type PresetOption } from './preset-group.js';
|
package/native/dist/selection.js
CHANGED
|
@@ -22,7 +22,7 @@ export interface SettingSwitchProps {
|
|
|
22
22
|
}
|
|
23
23
|
/** One setting as a switch: the label over an optional description on the leading edge, the track on the trailing edge. The whole row is the switch; the label names it and the description is its hint. */
|
|
24
24
|
export declare function SettingSwitch({ label, description, checked: requested, onCheckedChange, disabled, locked, labelAccessory, labelAccessoryLabel, testID }: SettingSwitchProps): React.JSX.Element;
|
|
25
|
-
/** The card a setting sits in. Inside a list the cards share one rounded container, so they drop their own radius. */
|
|
25
|
+
/** The card a setting sits in, as on web: 4 above and below the switch's own 48dp row, and 16 at the foot when content follows the switch (a channel's body, a signal's hint or error), 12 under the switch. Inside a list the cards share one rounded container, so they drop their own radius. */
|
|
26
26
|
export declare function SettingCard({ children, joined, testID }: React.PropsWithChildren<{
|
|
27
27
|
joined?: boolean;
|
|
28
28
|
testID?: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import { View } from 'react-native';
|
|
3
4
|
import { useColors, useFills, useHIG } from './provider.js';
|
|
4
5
|
import { Text } from './surface.js';
|
|
@@ -9,12 +10,15 @@ export function SettingSwitch({ label, description, checked: requested, onChecke
|
|
|
9
10
|
const checked = locked ? true : requested;
|
|
10
11
|
const name = _jsx(Text, { style: { fontSize: 16, lineHeight: 24, color: colors.text }, children: label });
|
|
11
12
|
const named = labelAccessoryLabel && labelAccessory != null && labelAccessory !== false ? `${label}, ${labelAccessoryLabel}` : label;
|
|
12
|
-
|
|
13
|
+
// As on web: the switch is a 48dp target (SwitchRow's own minimum) with 12 above and below the text, and the track sits on
|
|
14
|
+
// the first line. A row is 56dp in its card, 79dp with a one-line description (24 + 2 + 21 + 12 + 12, plus the card's 4 + 4).
|
|
15
|
+
return _jsx(SwitchRow, { testID: testID, label: named, accessibilityHint: description, checked: checked, disabled: locked ? true : disabled, onCheckedChange: onCheckedChange, style: { opacity: disabled ? 0.5 : 1 }, children: _jsxs(View, { style: { direction, flex: 1, flexDirection: 'row', alignItems: 'flex-start', gap: 12, paddingVertical: 12 }, children: [_jsxs(View, { style: { flex: 1, minWidth: 0, gap: 2 }, children: [labelAccessory != null && labelAccessory !== false ? _jsxs(View, { testID: testID ? `${testID}-label` : undefined, style: { direction, flexDirection: 'row', alignItems: 'center', flexWrap: 'wrap', gap: 8 }, children: [name, labelAccessory] }) : name, description ? _jsx(Text, { style: { fontSize: 14, lineHeight: 21, color: colors.muted }, children: description }) : null] }), _jsx(View, { testID: testID ? `${testID}-track` : undefined, style: { width: 40, height: 24, borderRadius: 12, padding: 3, backgroundColor: checked ? colors.action : fills.raised, alignItems: checked ? 'flex-end' : 'flex-start' }, children: _jsx(View, { style: { width: 18, height: 18, borderRadius: 9, backgroundColor: checked ? colors.onAction : colors.text } }) })] }) });
|
|
13
16
|
}
|
|
14
|
-
/** The card a setting sits in. Inside a list the cards share one rounded container, so they drop their own radius. */
|
|
17
|
+
/** The card a setting sits in, as on web: 4 above and below the switch's own 48dp row, and 16 at the foot when content follows the switch (a channel's body, a signal's hint or error), 12 under the switch. Inside a list the cards share one rounded container, so they drop their own radius. */
|
|
15
18
|
export function SettingCard({ children, joined, testID }) {
|
|
16
19
|
const fills = useFills();
|
|
17
|
-
|
|
20
|
+
const extended = React.Children.toArray(children).length > 1;
|
|
21
|
+
return _jsx(View, { testID: testID, style: { gap: 12, paddingTop: 4, paddingBottom: extended ? 16 : 4, paddingHorizontal: 20, borderRadius: joined ? 0 : 20, backgroundColor: fills.well }, children: children });
|
|
18
22
|
}
|
|
19
23
|
/** The shared header of a settings screen: Back on the leading edge, the title centred, a host control on the trailing edge. */
|
|
20
24
|
export { SettingHeader } from './setting-header.js';
|
package/native/dist/slider.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { numericRange } from '@bloxwap/hig/contracts';
|
|
2
3
|
import { View, Platform, UIManager, requireNativeComponent } from 'react-native';
|
|
3
4
|
import SliderBackend from '@react-native-community/slider';
|
|
4
5
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
@@ -9,7 +10,10 @@ import { Text } from './surface.js';
|
|
|
9
10
|
// {actionName:'setProgress',value}; without native linking (Expo Go, web, tests) the wrapper stays a plain View.
|
|
10
11
|
const AndroidAdjustable = Platform.OS === 'android' && UIManager.hasViewManagerConfig?.('HIGAdjustableView') ? requireNativeComponent('HIGAdjustableView') : null;
|
|
11
12
|
export function Slider({ label, value, defaultValue = 0, min = 0, max = 100, step = 1, disabled, onValueChange }) {
|
|
12
|
-
const
|
|
13
|
+
const range = numericRange(min, max, step);
|
|
14
|
+
const [stored, commit] = useControllable(value, defaultValue, onValueChange);
|
|
15
|
+
const current = range.clamp(stored);
|
|
16
|
+
const set = (next) => commit(range.clamp(next));
|
|
13
17
|
const { messages } = useHIG();
|
|
14
18
|
const colors = useColors();
|
|
15
19
|
const fills = useFills();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
-
import { formatNumber } from '
|
|
3
|
+
import { formatNumber } from './number-format.js';
|
|
4
4
|
import { useColors, useFills, useHIG, useNumberLocale } from './provider.js';
|
|
5
5
|
import { Text } from './surface.js';
|
|
6
6
|
import { Button } from './button.js';
|
package/native/dist/status.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type
|
|
2
|
+
import { type AvatarFrameProps } from './avatar-frame.js';
|
|
3
|
+
import { type DimensionValue, type StyleProp, type ViewProps, type ViewStyle, type TextProps } from 'react-native';
|
|
3
4
|
import { type AccentRole } from './roles.js';
|
|
4
5
|
export type { AccentRole } from './roles.js';
|
|
5
6
|
declare const severityRole: {
|
|
@@ -12,8 +13,16 @@ declare const severityRole: {
|
|
|
12
13
|
};
|
|
13
14
|
/** `note` and `tip` are documentation callout severities that reuse the info and positive token roles; `default` is the neutral variant (a faint `text` tint, title in `text`). */
|
|
14
15
|
export type AlertSeverity = keyof typeof severityRole | 'default';
|
|
16
|
+
/** A badge's meaning, as on web: explicit, never inferred from text or a number's sign. */
|
|
17
|
+
export type BadgeTone = 'neutral' | 'positive' | 'negative' | 'warning' | 'info';
|
|
18
|
+
export interface BadgeProps {
|
|
19
|
+
children?: React.ReactNode; /** `positive`, `negative`, `warning` or `info` draws the label in that token role over a 15% wash of it, like web `.hig-badge[data-tone]`; `neutral` (default) keeps the well fill. */
|
|
20
|
+
tone?: BadgeTone; /** A 6dp status dot in the label colour on the leading edge, hidden from assistive technology. */
|
|
21
|
+
dot?: boolean;
|
|
22
|
+
testID?: string;
|
|
23
|
+
}
|
|
15
24
|
/** Neutral chip in the dark well fill (one step lighter inside a Surface, Dialog or sheet). */
|
|
16
|
-
export declare function Badge({ children }:
|
|
25
|
+
export declare function Badge({ children, tone, dot, testID }: BadgeProps): React.JSX.Element;
|
|
17
26
|
/** Severity tints the fill 10% and colours the title from a token role (info/note → info, success/tip → positive, warning, error → negative; default → 6% of `text`), with no stroke or glow; `tone` swaps in another approved token role, never a raw colour. A non-string title renders inside the Heading, so pass strings or inline Text; its visible text is announced. A string or number child is drawn in a HIG `Text`. `announce` (default true) speaks the title and body when they appear or change; pass `false` for guidance that is present from the start. */
|
|
18
27
|
export declare function Alert({ title, children: body, severity, tone, action, announce }: React.PropsWithChildren<{
|
|
19
28
|
title: React.ReactNode;
|
|
@@ -41,6 +50,23 @@ export interface ToastProps {
|
|
|
41
50
|
maxHeight?: DimensionValue;
|
|
42
51
|
testID?: string;
|
|
43
52
|
}
|
|
53
|
+
export interface ToastNoticeProps {
|
|
54
|
+
message: string;
|
|
55
|
+
/** A second line under the message, in regular weight. */
|
|
56
|
+
description?: string;
|
|
57
|
+
severity?: Notice['severity'];
|
|
58
|
+
action?: React.ReactNode;
|
|
59
|
+
/** Accessible name of the close control; defaults to HIGProvider `messages.dismissNotice` around the message. */
|
|
60
|
+
dismissName?: string;
|
|
61
|
+
/** Draws the close control and takes its press. Omitted, the notice has none. */
|
|
62
|
+
onDismiss?: () => void;
|
|
63
|
+
/** Sizes the capsule to its content, up to the room it has, instead of filling its parent. `Toaster` draws it this way. Default `false`. */
|
|
64
|
+
hug?: boolean;
|
|
65
|
+
/** Merged over the capsule's fill, radius and shadow. */
|
|
66
|
+
style?: StyleProp<ViewStyle>;
|
|
67
|
+
}
|
|
68
|
+
/** One notice as a single capsule row: severity symbol on the leading edge, message with an optional description under it, optional action, close on the trailing edge. Shared by `Toast` and the transient `Toaster` of `@bloxwap/hig/native/toast`; it announces nothing itself. */
|
|
69
|
+
export declare function ToastNotice({ message, description, severity, action, dismissName, onDismiss, hug, style }: ToastNoticeProps): React.JSX.Element;
|
|
44
70
|
/** Each notice is one capsule row: severity symbol, message, optional action, then a close control. Compact, scrollable notices remain visible until their host removes them. */
|
|
45
71
|
export declare function Toast({ notices, onDismiss, dismissLabel, maxHeight, testID }: ToastProps): React.JSX.Element;
|
|
46
72
|
/** One transient notice: shown for about four seconds, replaced by the next one, dismissible, and cleared on unmount. Render it with `Toast`, which announces it. */
|
|
@@ -49,9 +75,14 @@ export declare function useTransientNotice(duration?: number): {
|
|
|
49
75
|
show: (message: string, severity?: Notice['severity']) => void;
|
|
50
76
|
dismiss: () => void;
|
|
51
77
|
};
|
|
52
|
-
export
|
|
78
|
+
export interface SpinnerProps {
|
|
79
|
+
/** What is loading; defaults to HIGProvider `messages.loading`. */
|
|
53
80
|
label?: string;
|
|
54
|
-
|
|
81
|
+
/** Draws the indicator alone, for a tight spot such as a row or a button-sized slot: the label is not drawn but stays the element's accessibility label. */
|
|
82
|
+
hideLabel?: boolean;
|
|
83
|
+
testID?: string;
|
|
84
|
+
}
|
|
85
|
+
export declare function Spinner({ label, hideLabel, testID }: SpinnerProps): React.JSX.Element;
|
|
55
86
|
export declare function Progress({ label, value, max, hideValue }: {
|
|
56
87
|
label: string;
|
|
57
88
|
value?: number;
|
|
@@ -75,11 +106,12 @@ export interface EmptyStateProps extends Omit<ViewProps, 'children'> {
|
|
|
75
106
|
}
|
|
76
107
|
/** A strokeless card, centred: icon, title, optional description, then the action. */
|
|
77
108
|
export declare function EmptyState({ title, description, action, illustration, titleStyle, descriptionStyle, maxFontSizeMultiplier, ...props }: EmptyStateProps): React.JSX.Element;
|
|
78
|
-
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
109
|
+
/**
|
|
110
|
+
* A person or account as a 40dp disc: an image, else the first two letters of the name on the well fill (one step lighter inside a Surface, Dialog or sheet).
|
|
111
|
+
* `size`, `square` and `decorative` are as in `@bloxwap/hig/native/avatar`, whose `Avatar` also draws a face generated from a seed; that entry needs `react-native-svg` and this one does not.
|
|
112
|
+
* It renders again only when one of its props changes.
|
|
113
|
+
*/
|
|
114
|
+
export declare function Avatar(props: AvatarFrameProps): React.JSX.Element;
|
|
83
115
|
/** The dot carries the state colour. Online and stale emit a ring that grows and fades in that colour; offline and reduced motion stay still. */
|
|
84
116
|
export declare function StatusIndicator({ label, state }: {
|
|
85
117
|
label: string;
|
package/native/dist/status.js
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { progressValue } from '@bloxwap/hig/contracts';
|
|
2
3
|
import React, { useEffect, useRef, useState } from 'react';
|
|
3
4
|
import { tokens } from '@bloxwap/hig/tokens';
|
|
4
5
|
import { CloseIcon, EmptyIcon, SeverityIcon } from './icons.js';
|
|
5
6
|
import { notificationDelta } from '@bloxwap/hig/contracts/announcements';
|
|
6
|
-
import {
|
|
7
|
+
import { AvatarFrame, sameFrame } from './avatar-frame.js';
|
|
8
|
+
import { ActivityIndicator, Animated, Easing, View, ScrollView, useWindowDimensions, Platform } from 'react-native';
|
|
7
9
|
import { Text, Heading, Surface, Stack } from './surface.js';
|
|
8
|
-
import { formatNumber } from '
|
|
10
|
+
import { formatNumber } from './number-format.js';
|
|
9
11
|
import { Button } from './button.js';
|
|
10
12
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
11
13
|
import { useColors, useFills, useHIG } from './provider.js';
|
|
12
14
|
import { blockText, plainText } from './text-content.js';
|
|
13
15
|
import { roleColor } from './roles.js';
|
|
16
|
+
import { speak } from './announce.js';
|
|
14
17
|
const severityRole = { info: 'info', note: 'info', success: 'positive', tip: 'positive', warning: 'warning', error: 'negative' };
|
|
15
|
-
function speak(message, severity) { if (Platform.OS === 'web' || !message)
|
|
16
|
-
return; try {
|
|
17
|
-
if (Platform.OS === 'ios' && typeof AccessibilityInfo.announceForAccessibilityWithOptions === 'function')
|
|
18
|
-
AccessibilityInfo.announceForAccessibilityWithOptions(message, { queue: severity !== 'error' });
|
|
19
|
-
else
|
|
20
|
-
AccessibilityInfo.announceForAccessibility(message);
|
|
21
|
-
}
|
|
22
|
-
catch { /* The visible message and navigable text remain available. */ } }
|
|
23
18
|
/** Neutral chip in the dark well fill (one step lighter inside a Surface, Dialog or sheet). */
|
|
24
|
-
export function Badge({ children
|
|
19
|
+
export function Badge({ children, tone = 'neutral', dot, testID }) {
|
|
20
|
+
const fills = useFills();
|
|
21
|
+
const colors = useColors();
|
|
22
|
+
const accent = tone === 'positive' || tone === 'negative' || tone === 'warning' || tone === 'info' ? colors[tone] : undefined;
|
|
23
|
+
/* 15% of the role over whatever is behind, as web color-mix with transparent; a colour that is not #rrggbb blends into the well instead. */
|
|
24
|
+
const fill = accent ? (/^#[0-9a-f]{6}$/i.test(accent) ? `${accent}26` : tint(accent, fills.well, 0.15)) : fills.well;
|
|
25
|
+
const chip = { alignSelf: 'flex-start', maxWidth: '100%', backgroundColor: fill, overflow: 'hidden', borderRadius: 9999, paddingVertical: 4, paddingHorizontal: 10 };
|
|
26
|
+
const label = accent ? { color: accent } : null;
|
|
27
|
+
return dot ? _jsxs(View, { testID: testID, style: [chip, { flexDirection: 'row', alignItems: 'center', gap: 6 }], children: [_jsx(View, { accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', style: { width: 6, height: 6, borderRadius: 3, backgroundColor: accent ?? colors.text } }), _jsx(Text, { style: [label, { flexShrink: 1 }], children: children })] }) : _jsx(Text, { testID: testID, style: label ? [chip, label] : chip, children: children });
|
|
28
|
+
}
|
|
25
29
|
/** Opaque sRGB blend of `tone` into `base` (both `#rrggbb`): the native counterpart of CSS `color-mix`. */
|
|
26
30
|
const tint = (tone, base, amount) => '#' + [1, 3, 5].map(i => Math.round(parseInt(base.slice(i, i + 2), 16) * (1 - amount) + parseInt(tone.slice(i, i + 2), 16) * amount).toString(16).padStart(2, '0')).join('');
|
|
27
31
|
/** Severity tints the fill 10% and colours the title from a token role (info/note → info, success/tip → positive, warning, error → negative; default → 6% of `text`), with no stroke or glow; `tone` swaps in another approved token role, never a raw colour. A non-string title renders inside the Heading, so pass strings or inline Text; its visible text is announced. A string or number child is drawn in a HIG `Text`. `announce` (default true) speaks the title and body when they appear or change; pass `false` for guidance that is present from the start. */
|
|
@@ -37,10 +41,16 @@ function useLoop(active, duration, easing = Easing.linear) { const value = useRe
|
|
|
37
41
|
value.setValue(0);
|
|
38
42
|
return;
|
|
39
43
|
} const loop = Animated.loop(Animated.timing(value, { toValue: 1, duration, easing, useNativeDriver: Platform.OS !== 'web', isInteraction: false })); loop.start(); return () => loop.stop(); }, [active, duration, easing, value]); return value; }
|
|
40
|
-
/**
|
|
41
|
-
export function
|
|
44
|
+
/** One notice as a single capsule row: severity symbol on the leading edge, message with an optional description under it, optional action, close on the trailing edge. Shared by `Toast` and the transient `Toaster` of `@bloxwap/hig/native/toast`; it announces nothing itself. */
|
|
45
|
+
export function ToastNotice({ message, description, severity = 'info', action, dismissName, onDismiss, hug = false, style }) {
|
|
42
46
|
const { messages, direction } = useHIG();
|
|
43
47
|
const colors = useColors();
|
|
48
|
+
const close = onDismiss ? _jsx(Button, { intent: 'ghost', contentMode: 'custom', suppressFeedback: true, accessibilityLabel: dismissName ?? (messages.dismissNotice ?? en.dismissNotice)(message, messages.dismiss ?? en.dismiss), hitSlop: 8, onPress: onDismiss, style: { minHeight: 32, minWidth: 32, paddingHorizontal: 0, paddingVertical: 0, alignSelf: 'center' }, children: _jsx(CloseIcon, { color: colors.muted }) }) : null;
|
|
49
|
+
return _jsxs(View, { accessibilityLiveRegion: 'none', style: [{ direction, flexDirection: 'row', alignItems: 'center', gap: 10, minHeight: 44, paddingVertical: 6, paddingHorizontal: 12, borderRadius: 22, backgroundColor: colors.nested, boxShadow: '0 4px 16px #0006' }, style], children: [_jsx(SeverityIcon, { kind: severity, color: colors[severityRole[severity]] }), _jsxs(View, { style: hug ? { flexShrink: 1, minWidth: 0 } : { flex: 1, minWidth: 0 }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: message }), description ? _jsx(Text, { children: description }) : null] }), action, close] });
|
|
50
|
+
}
|
|
51
|
+
/** Each notice is one capsule row: severity symbol, message, optional action, then a close control. Compact, scrollable notices remain visible until their host removes them. */
|
|
52
|
+
export function Toast({ notices, onDismiss, dismissLabel, maxHeight, testID }) {
|
|
53
|
+
const { messages } = useHIG();
|
|
44
54
|
const { height } = useWindowDimensions();
|
|
45
55
|
const dismiss = dismissLabel ?? messages.dismiss ?? en.dismiss;
|
|
46
56
|
const unique = [...new Map(notices.map(n => [n.id, n])).values()];
|
|
@@ -65,7 +75,7 @@ export function Toast({ notices, onDismiss, dismissLabel, maxHeight, testID }) {
|
|
|
65
75
|
}, [key]);
|
|
66
76
|
useEffect(() => () => { if (timer.current !== null)
|
|
67
77
|
clearTimeout(timer.current); }, []);
|
|
68
|
-
return _jsxs(View, { testID: testID, style: { maxHeight: maxHeight ?? height * .6, flexShrink: 1 }, children: [_jsx(ScrollView, { style: { flexGrow: 0, flexShrink: 1 }, nestedScrollEnabled: true, keyboardShouldPersistTaps: 'handled', accessibilityLabel: messages.notifications ?? en.notifications, children: _jsx(Stack, { style: { gap: 8 }, children: unique.map(n =>
|
|
78
|
+
return _jsxs(View, { testID: testID, style: { maxHeight: maxHeight ?? height * .6, flexShrink: 1 }, children: [_jsx(ScrollView, { style: { flexGrow: 0, flexShrink: 1 }, nestedScrollEnabled: true, keyboardShouldPersistTaps: 'handled', accessibilityLabel: messages.notifications ?? en.notifications, children: _jsx(Stack, { style: { gap: 8 }, children: unique.map(n => _jsx(ToastNotice, { message: n.message, description: n.description, severity: n.severity, action: n.action, dismissName: (messages.dismissNotice ?? en.dismissNotice)(n.message, dismiss), onDismiss: n.closable !== false && onDismiss ? () => onDismiss(n.id) : undefined }, n.id)) }) }), Platform.OS === 'web' && _jsx(Text, { accessibilityLiveRegion: 'polite', style: { position: 'absolute', width: 1, height: 1, overflow: 'hidden' }, children: announcement })] });
|
|
69
79
|
}
|
|
70
80
|
/** One transient notice: shown for about four seconds, replaced by the next one, dismissible, and cleared on unmount. Render it with `Toast`, which announces it. */
|
|
71
81
|
export function useTransientNotice(duration = 4000) {
|
|
@@ -80,8 +90,9 @@ export function useTransientNotice(duration = 4000) {
|
|
|
80
90
|
return { notice, dismiss: () => { stop(); setNotice(null); }, show: (message, severity = 'success') => { if (!alive.current)
|
|
81
91
|
return; stop(); setNotice({ id: `notice-${++sequence.current}`, message, severity }); timer.current = setTimeout(() => { timer.current = null; setNotice(null); }, duration); } };
|
|
82
92
|
}
|
|
83
|
-
export function Spinner({ label }) { const { messages } = useHIG(); const colors = useColors(); const text = label ?? messages.loading ?? en.loading; return _jsxs(View, { accessible: true, accessibilityLabel: text, children: [_jsx(ActivityIndicator, { color: colors.action }), _jsx(Text, { children: text })] }); }
|
|
93
|
+
export function Spinner({ label, hideLabel, testID }) { const { messages } = useHIG(); const colors = useColors(); const text = label ?? messages.loading ?? en.loading; return _jsxs(View, { testID: testID, accessible: true, accessibilityLabel: text, children: [_jsx(ActivityIndicator, { color: colors.action }), hideLabel ? null : _jsx(Text, { children: text })] }); }
|
|
84
94
|
export function Progress({ label, value, max = 100, hideValue }) {
|
|
95
|
+
({ value, max } = progressValue(value, max));
|
|
85
96
|
const { locale, messages, direction } = useHIG();
|
|
86
97
|
const colors = useColors();
|
|
87
98
|
const fills = useFills();
|
|
@@ -96,8 +107,14 @@ export function EmptyState({ title, description, action, illustration, titleStyl
|
|
|
96
107
|
const mark = illustration !== undefined ? illustration : _jsx(EmptyIcon, { color: colors.muted });
|
|
97
108
|
return _jsxs(Surface, { ...props, style: [{ gap: 12, alignItems: 'center' }, props.style], children: [mark != null && _jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: mark }), _jsx(Heading, { style: [{ textAlign: 'center' }, titleStyle], maxFontSizeMultiplier: maxFontSizeMultiplier, children: title }), description ? _jsx(Text, { style: [{ textAlign: 'center', color: colors.muted }, descriptionStyle], maxFontSizeMultiplier: maxFontSizeMultiplier, children: description }) : null, action] });
|
|
98
109
|
}
|
|
99
|
-
/**
|
|
100
|
-
|
|
110
|
+
/** The Avatar frame, kept while its props are the same: a list that renders again renders no frame for the rows that did not change. */
|
|
111
|
+
const StillFrame = React.memo(AvatarFrame, sameFrame);
|
|
112
|
+
/**
|
|
113
|
+
* A person or account as a 40dp disc: an image, else the first two letters of the name on the well fill (one step lighter inside a Surface, Dialog or sheet).
|
|
114
|
+
* `size`, `square` and `decorative` are as in `@bloxwap/hig/native/avatar`, whose `Avatar` also draws a face generated from a seed; that entry needs `react-native-svg` and this one does not.
|
|
115
|
+
* It renders again only when one of its props changes.
|
|
116
|
+
*/
|
|
117
|
+
export function Avatar(props) { return _jsx(StillFrame, { ...props }); }
|
|
101
118
|
const statusRole = { online: 'positive', stale: 'warning', offline: 'muted' };
|
|
102
119
|
const ringEasing = Easing.out(Easing.quad);
|
|
103
120
|
/** The dot carries the state colour. Online and stale emit a ring that grows and fades in that colour; offline and reduced motion stay still. */
|
|
@@ -14,8 +14,16 @@ export function useStickyHeaderScroll(onScroll) {
|
|
|
14
14
|
}
|
|
15
15
|
/** The fill of a pinned header: transparent at rest so what the host draws behind it shows through, `background` once content has scrolled under it. */
|
|
16
16
|
export function stickyHeaderFill(scrolled, background) { return { backgroundColor: scrolled ? background : 'transparent' }; }
|
|
17
|
+
const stickySlotStyle = { flexDirection: 'row' };
|
|
18
|
+
const stickyScrollStyle = { flexGrow: 1, flexShrink: 1, minHeight: 0 };
|
|
17
19
|
/** A block as its own scroll view with its header pinned: 16dp around the content as the block draws it, the header transparent until content scrolls under it. Place it in a bounded container, such as a sheet body. */
|
|
18
20
|
export function StickyHeaderLayout({ header, children, background, scrollComponent: Scroll = ScrollView, testID, headerTestID, bodyStyle }) {
|
|
19
21
|
const colors = useColors(), { scrolled, onScroll, scrollEventThrottle } = useStickyHeaderScroll();
|
|
20
|
-
|
|
22
|
+
// React Native's sticky slot moves the pinned child's style onto its own wrapper and gives the child flex:1, which measures 0 tall in a column.
|
|
23
|
+
// So the pinned child carries only a row direction (the wrapper lays out as a row, where flex:1 fills the width and the height follows content),
|
|
24
|
+
// and the inset and fill sit on the inner view, which keeps its full height whether or not the scroller pins it.
|
|
25
|
+
// The scroller fills a bounded parent and may shrink below its content, whatever scroll component the host passes, so the
|
|
26
|
+
// content scrolls inside it. It cannot bound itself: in a parent whose height follows its content (a View with no flex or
|
|
27
|
+
// height, a content-sized sheet) it grows to its content and nothing scrolls.
|
|
28
|
+
return _jsxs(Scroll, { testID: testID, style: stickyScrollStyle, stickyHeaderIndices: [0], onScroll: onScroll, scrollEventThrottle: scrollEventThrottle, contentContainerStyle: { paddingBottom: 16 }, children: [_jsx(View, { style: stickySlotStyle, children: _jsx(View, { testID: headerTestID, style: [{ flexGrow: 1, paddingHorizontal: 16, paddingTop: 16 }, stickyHeaderFill(scrolled, background ?? colors.background)], children: header }) }), _jsx(View, { style: [{ paddingHorizontal: 16 }, bodyStyle], children: children })] });
|
|
21
29
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type PressableProps, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import type { SwapArtwork } from './swap-shared.js';
|
|
4
|
+
export interface SwapPillProps extends Omit<PressableProps, 'children' | 'style' | 'accessibilityRole' | 'accessibilityState'> {
|
|
5
|
+
/** The pill's text, drawn small and muted, such as Max; or host nodes drawn as given, such as a live figure. */
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/** Called on a press. */
|
|
8
|
+
onPress?: () => void;
|
|
9
|
+
/** Dims the pill, ignores presses and reads as unavailable. */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** A small capsule action on a swap card, as the web `SwapPill`: Max, Test, a converted value. 32dp tall with a 44dp target; text is drawn small and muted, and other children as given. Other Pressable props, such as `accessibilityLabel`, `testID` or `android_disableSound`, reach it. */
|
|
13
|
+
export declare function SwapPill({ children, onPress, disabled, hitSlop, ...props }: SwapPillProps): React.JSX.Element;
|
|
14
|
+
export interface SwapAmountCardProps {
|
|
15
|
+
/** Asset name, drawn in the slot. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Asset symbol; its first letters stand in when there is no `icon`. */
|
|
18
|
+
symbol: string;
|
|
19
|
+
/** Asset artwork: an image URL, or an element the host draws. */
|
|
20
|
+
icon?: SwapArtwork;
|
|
21
|
+
/** Chain or venue artwork, stacked above the asset. */
|
|
22
|
+
chainIcon?: string;
|
|
23
|
+
/** Line above the name: the chain, venue or account the amount comes from. A string is drawn small and muted. */
|
|
24
|
+
context?: React.ReactNode;
|
|
25
|
+
/** Capsule actions on the trailing edge, such as Max. Use `SwapPill`. They stay their own targets. */
|
|
26
|
+
actions?: React.ReactNode;
|
|
27
|
+
/** Supporting line under the actions, such as the available balance. A string is drawn small and muted; a node, such as a live figure, as given. */
|
|
28
|
+
meta?: React.ReactNode;
|
|
29
|
+
/** The entered amount. */
|
|
30
|
+
value: number;
|
|
31
|
+
/** Accessible name of the amount: From amount. */
|
|
32
|
+
amountLabel: string;
|
|
33
|
+
/** Text before the amount, such as a currency sign. */
|
|
34
|
+
prefix?: string;
|
|
35
|
+
/** Text after the amount, such as a percent sign. */
|
|
36
|
+
suffix?: string;
|
|
37
|
+
/** Decimal places typed so far, so `1.50` keeps its zero. */
|
|
38
|
+
fractionDigits?: number;
|
|
39
|
+
/** Set while the entry ends with a decimal point that has no digits after it yet. */
|
|
40
|
+
trailingDot?: boolean;
|
|
41
|
+
/** Most decimal places the amount can show. Defaults to 8. */
|
|
42
|
+
maximumFractionDigits?: number;
|
|
43
|
+
/** Capsule under the amount, such as the converted value. Use `SwapPill`. */
|
|
44
|
+
conversion?: React.ReactNode;
|
|
45
|
+
/** Makes the slot a button that chooses the asset. Requires `selectLabel`. */
|
|
46
|
+
onSelect?: () => void;
|
|
47
|
+
/** Accessible name of the slot's button: Select token, From. */
|
|
48
|
+
selectLabel?: string;
|
|
49
|
+
style?: StyleProp<ViewStyle>;
|
|
50
|
+
/** Prefix of the test IDs: `<testID>` (the card), `-slot`, `-select`, `-name`, `-context`, `-actions`, `-meta`, `-amount` and `-conversion`. Defaults to `swap-amount-card`. */
|
|
51
|
+
testID?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The swap panel's From card on its own, as the web `SwapAmountCard`: the asset with its actions and balance in the slot, the entered amount
|
|
55
|
+
* under it. The host owns the entry, the keypad and what the amount means.
|
|
56
|
+
*/
|
|
57
|
+
export declare function SwapAmountCard({ name, symbol, icon, chainIcon, context, actions, meta, value, amountLabel, prefix, suffix, fractionDigits, trailingDot, maximumFractionDigits, conversion, onSelect, selectLabel, style, testID }: SwapAmountCardProps): React.JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Pressable, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { formatNumber } from './number-format.js';
|
|
4
|
+
import { Raised, useColors, useFills, useHIG, useNumberLocale } from './provider.js';
|
|
5
|
+
import { Text } from './surface.js';
|
|
6
|
+
import { AnimatedNumberReadout } from './animated-number.js';
|
|
7
|
+
import { TokenArt } from './swap-parts.js';
|
|
8
|
+
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
9
|
+
const smallType = { fontSize: 14, lineHeight: 19 };
|
|
10
|
+
/** Test ID parts. */
|
|
11
|
+
const contextPart = 'context', metaPart = 'meta';
|
|
12
|
+
/** A small capsule action on a swap card, as the web `SwapPill`: Max, Test, a converted value. 32dp tall with a 44dp target; text is drawn small and muted, and other children as given. Other Pressable props, such as `accessibilityLabel`, `testID` or `android_disableSound`, reach it. */
|
|
13
|
+
export function SwapPill({ children, onPress, disabled, hitSlop, ...props }) {
|
|
14
|
+
const colors = useColors(), fills = useFills(), { direction } = useHIG();
|
|
15
|
+
const text = typeof children === 'string' || typeof children === 'number';
|
|
16
|
+
return _jsx(Pressable, { ...props, accessibilityRole: 'button', accessibilityState: { disabled: !!disabled }, disabled: disabled, onPress: onPress, hitSlop: hitSlop ?? { top: 6, bottom: 6 }, style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', gap: 6, minHeight: 32, paddingVertical: 4, paddingHorizontal: 12, borderRadius: 9999, backgroundColor: pressed && !disabled ? fills.raised : fills.well, opacity: disabled ? 0.5 : 1 }), children: text ? _jsx(Text, { style: { ...smallType, color: colors.muted }, children: children }) : children });
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The swap panel's From card on its own, as the web `SwapAmountCard`: the asset with its actions and balance in the slot, the entered amount
|
|
20
|
+
* under it. The host owns the entry, the keypad and what the amount means.
|
|
21
|
+
*/
|
|
22
|
+
export function SwapAmountCard({ name, symbol, icon, chainIcon, context, actions, meta, value, amountLabel, prefix = '', suffix = '', fractionDigits = 0, trailingDot = false, maximumFractionDigits = 8, conversion, onSelect, selectLabel, style, testID = 'swap-amount-card' }) {
|
|
23
|
+
const colors = useColors(), { direction } = useHIG(), locale = useNumberLocale();
|
|
24
|
+
const id = (part) => `${testID}-${part}`;
|
|
25
|
+
const small = { ...smallType, color: colors.muted };
|
|
26
|
+
const options = { minimumFractionDigits: Math.min(fractionDigits, maximumFractionDigits), maximumFractionDigits, useGrouping: false };
|
|
27
|
+
const after = (trailingDot ? '.' : '') + suffix;
|
|
28
|
+
const line = (node, part) => typeof node === 'string' || typeof node === 'number' ? _jsx(Text, { testID: id(part), style: small, children: node }) : _jsx(View, { testID: id(part), children: node });
|
|
29
|
+
const shown = (node) => node != null && node !== false;
|
|
30
|
+
return _jsx(View, { testID: testID, style: [{ direction, backgroundColor: colors.surface, borderRadius: 24, overflow: 'hidden' }, style], children: _jsxs(Raised, { children: [_jsxs(View, { testID: id('slot'), children: [onSelect ? _jsx(Pressable, { testID: id('select'), accessibilityRole: 'button', accessibilityLabel: selectLabel, onPress: onSelect, style: StyleSheet.absoluteFill }) : null, _jsxs(View, { pointerEvents: 'box-none', style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 84, padding: 16 }, children: [_jsxs(View, { pointerEvents: 'none', style: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'flex-start', gap: 12 }, children: [_jsxs(View, { ...hidden, style: { alignItems: 'center' }, children: [chainIcon ? _jsx(TokenArt, { uri: chainIcon, size: 28, ring: colors.surface }) : null, _jsx(View, { style: { marginTop: chainIcon ? -14 : 0 }, children: _jsx(TokenArt, { uri: icon, symbol: symbol, size: 28, ring: colors.surface }) })] }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [shown(context) ? line(context, contextPart) : null, _jsx(Text, { testID: id('name'), style: { fontWeight: '600', lineHeight: 21 }, children: name })] })] }), shown(actions) || shown(meta) ? _jsxs(View, { pointerEvents: 'box-none', style: { alignItems: 'flex-end', gap: 8, maxWidth: '60%' }, children: [shown(actions) ? _jsx(View, { testID: id('actions'), pointerEvents: 'box-none', style: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'flex-end', gap: 8 }, children: actions }) : null, shown(meta) ? line(meta, metaPart) : null] }) : null] })] }), _jsxs(View, { pointerEvents: 'box-none', style: { alignItems: 'center', gap: 8, paddingTop: 4, paddingHorizontal: 16, paddingBottom: 20 }, children: [_jsx(View, { accessible: true, accessibilityLabel: amountLabel, accessibilityValue: { text: `${prefix}${formatNumber(value, locale, options)}${after}` }, testID: id('amount'), children: _jsx(AnimatedNumberReadout, { value: value, prefix: prefix, suffix: after, options: options, maxFontSizeMultiplier: 1.5, style: { fontSize: 44, lineHeight: 50, fontWeight: '700', letterSpacing: -0.9, textAlign: 'center' } }) }), shown(conversion) ? _jsx(View, { testID: id('conversion'), children: conversion }) : null] })] }) });
|
|
31
|
+
}
|
|
@@ -4,6 +4,7 @@ import { type SwapAction, type SwapArtwork, type SwapChain, type SwapDenominatio
|
|
|
4
4
|
export { swapAction, swapParentView, type SwapAction, type SwapArtwork, type SwapChain, type SwapDenomination, type SwapFee, type SwapFigure, type SwapToken, type SwapView, type SwapWallet } from './swap-shared.js';
|
|
5
5
|
/** What a host surface lends the panel. A sheet passes its backend's list, so list drags hand off to the sheet, and sizes itself, so the panel does not animate its own height. */
|
|
6
6
|
export { SwapHostContext } from './swap-parts.js';
|
|
7
|
+
export { SwapAmountCard, SwapPill, type SwapAmountCardProps, type SwapPillProps } from './swap-amount-card.js';
|
|
7
8
|
/** A fixed place the assets go, in place of a token the user picks: a wallet, a staking pool, a trading account. Shown as a compact To card with no amount. */
|
|
8
9
|
export interface SwapDestination {
|
|
9
10
|
title: string;
|
|
@@ -35,7 +36,7 @@ export interface SwapReceive {
|
|
|
35
36
|
qr?: React.ReactNode; /** Host clipboard adapter. When set, the whole view copies the address. */
|
|
36
37
|
onCopy?: () => Promise<void> | void;
|
|
37
38
|
}
|
|
38
|
-
export interface
|
|
39
|
+
export interface SwapBlockProps {
|
|
39
40
|
/** Catalog for the To side, and for the From side unless `fromTokens` is given. */
|
|
40
41
|
tokens: readonly SwapToken[];
|
|
41
42
|
/** Assets offered on the From side, typically the connected wallet's holdings. */
|
|
@@ -80,7 +81,10 @@ export interface SwapPanelBlockProps {
|
|
|
80
81
|
onReceivingChange?: (receiving: boolean) => void;
|
|
81
82
|
/** The host validates, quotes and executes. HIG never submits a transaction. */
|
|
82
83
|
onSubmit: (action: SwapAction) => void;
|
|
84
|
+
/** The host's submit is in flight: the action shows a spinner and ignores presses, the keypad, Max and Test leave the amount as it is, and the action keeps its ready name (or `submittingLabel`, or a held action's `actionStatus`) even when the host has cleared the amount meanwhile, never “Enter an amount” or the balance check. */
|
|
83
85
|
submitting?: boolean;
|
|
86
|
+
/** What the action says while `submitting`, in place of its ready name: Burning…. Host text. */
|
|
87
|
+
submittingLabel?: string;
|
|
84
88
|
/** Called after the panel clears its entry and both tokens (through `onFromChange(null)` / `onToChange(null)`), so the host can drop its quote. */
|
|
85
89
|
onReset?: () => void;
|
|
86
90
|
/** On native there is no hardware keyboard to rely on, so `auto` shows the keypad; `never` hides it. */
|
|
@@ -93,9 +97,11 @@ export interface SwapPanelBlockProps {
|
|
|
93
97
|
/** A line under the cards: a limit, a delay, a warning. `noteTone` tints it. */
|
|
94
98
|
note?: React.ReactNode;
|
|
95
99
|
noteTone?: 'muted' | 'warning' | 'negative';
|
|
96
|
-
/** Heading above the cards, for a panel that is its own screen or sheet. `onBack` adds
|
|
100
|
+
/** Heading above the cards, for a panel that is its own screen or sheet, drawn as the shared `ScreenHeader` (the title centred, 17/24, in a 44dp row) like every other block. `onBack` adds Back on its leading edge. Test IDs `swap-header`, `swap-back` and `swap-title`. */
|
|
97
101
|
title?: string;
|
|
98
102
|
onBack?: () => void;
|
|
103
|
+
/** With `title`: `nativeID` of the heading, so a sheet around the panel can name itself with `accessibilityLabelledBy` (Android). */
|
|
104
|
+
headingId?: string;
|
|
99
105
|
/** `false` leaves the action button on its own, full width: no settings and no reset button. */
|
|
100
106
|
controls?: boolean;
|
|
101
107
|
/** Decoration before the action text. */
|
|
@@ -107,7 +113,7 @@ export interface SwapPanelBlockProps {
|
|
|
107
113
|
actionLabel?: string;
|
|
108
114
|
/** Holds the action for a reason only the host knows: below a minimum, no quote yet, a closed market. The panel's own checks (a token, an amount, the balance) still apply first. */
|
|
109
115
|
actionDisabled?: boolean;
|
|
110
|
-
/** What the held action says, for example “Below minimum
|
|
116
|
+
/** What the held action says, for example “Below minimum” or, while `submitting`, “Signing…” (a `submittingLabel` wins over it). Without it the action keeps its ready name. */
|
|
111
117
|
actionStatus?: string;
|
|
112
118
|
/** `destructive` for an action that cannot be undone, such as a burn. */
|
|
113
119
|
actionIntent?: 'primary' | 'destructive';
|
|
@@ -138,8 +144,12 @@ export interface SwapPanelBlockProps {
|
|
|
138
144
|
* or token units through the keypad, token pickers, settings, and one action that names itself from the chosen pair.
|
|
139
145
|
* Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
|
|
140
146
|
*/
|
|
141
|
-
export declare function
|
|
142
|
-
/** @deprecated Renamed `
|
|
143
|
-
export declare const SwapPanel: typeof
|
|
144
|
-
/** @deprecated Renamed `
|
|
145
|
-
export type SwapPanelProps =
|
|
147
|
+
export declare function SwapBlock({ tokens, fromTokens, fromTokensLoading, chains, hotTokenIds, from: fromProp, to: toProp, defaultFrom, defaultTo, onFromChange, onToChange, amount, onAmountChange, received, fee, fees, quoteLoading, slippage, onSlippageChange, denomination, onDenominationChange, wallet, onConnect, onDisconnect, recipient, onRecipientChange, onScanRecipient, receive, receiving, onReceivingChange, onSubmit, submitting, submittingLabel, onReset, keypad, destination, details, note, noteTone, title, onBack, headingId, controls, actionIcon, lockFrom, lockTo, actionLabel, actionDisabled, actionStatus, actionIntent, limitToBalance, banner, footer, oneWay: oneWayProp, denominationSwitch, settings, view: viewProp, onViewChange, style }: SwapBlockProps): React.JSX.Element;
|
|
148
|
+
/** @deprecated Renamed `SwapBlock`. The old name keeps working until the next major release. */
|
|
149
|
+
export declare const SwapPanel: typeof SwapBlock;
|
|
150
|
+
/** @deprecated Renamed `SwapBlockProps`. */
|
|
151
|
+
export type SwapPanelProps = SwapBlockProps;
|
|
152
|
+
/** @deprecated Use SwapBlock. */
|
|
153
|
+
export declare const SwapPanelBlock: typeof SwapBlock;
|
|
154
|
+
/** @deprecated Use SwapBlockProps. */
|
|
155
|
+
export type SwapPanelBlockProps = SwapBlockProps;
|