@bloxwap/hig 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/chart/README.md +13 -2
- package/chart/dist/altimeter-burst.d.ts +4 -0
- package/chart/dist/altimeter-burst.js +43 -0
- package/chart/dist/altimeter-chart.d.ts +52 -0
- package/chart/dist/altimeter-chart.js +275 -0
- package/chart/dist/altimeter-model.d.ts +43 -0
- package/chart/dist/altimeter-model.js +148 -0
- package/chart/dist/altimeter-targets.d.ts +33 -0
- package/chart/dist/altimeter-targets.js +88 -0
- package/chart/dist/bitcoin-price.d.ts +8 -0
- package/chart/dist/bitcoin-price.js +41 -0
- package/chart/dist/champions-league.d.ts +19 -0
- package/chart/dist/champions-league.js +104 -0
- package/chart/dist/index.d.ts +6 -0
- package/chart/dist/index.js +5 -0
- package/chart/dist/outcome-chart.d.ts +37 -0
- package/chart/dist/outcome-chart.js +212 -0
- package/chart/dist/outcome-model.d.ts +43 -0
- package/chart/dist/outcome-model.js +71 -0
- package/chart/dist/plus-grid.d.ts +6 -0
- package/chart/dist/plus-grid.js +29 -0
- package/contracts/README.md +1 -1
- package/contracts/dist/avatar.d.ts +68 -0
- package/contracts/dist/avatar.js +93 -0
- package/contracts/dist/confetti.d.ts +174 -0
- package/contracts/dist/confetti.js +138 -0
- package/contracts/dist/decimal.d.ts +7 -0
- package/contracts/dist/decimal.js +35 -0
- package/contracts/dist/index.d.ts +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/messages.d.ts +56 -2
- 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 +161 -16
- 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 +6 -1
- package/native/dist/blocks.js +5 -0
- 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.js +2 -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/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 +9 -3
- package/native/dist/swap-panel-block.js +59 -33
- 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-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 +10 -1
- package/native/dist/token-action-block.js +9 -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 +111 -2
- package/react/README.md +3 -1
- package/react/dist/animated-number-flow.d.ts +72 -0
- package/react/dist/animated-number-flow.js +316 -0
- package/react/dist/animated-number-model.d.ts +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/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/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 +10 -3
- package/react/dist/blocks/swap-panel-block.js +71 -36
- 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 +5 -1
- package/react/dist/blocks/token-action-block.js +2 -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 +5 -1
- package/react/dist/blocks.js +4 -0
- 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 +28 -3
- package/react/dist/overlay.js +29 -3
- package/react/dist/preset-group.d.ts +30 -0
- package/react/dist/preset-group.js +13 -0
- package/react/dist/provider.d.ts +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 +238 -163
- 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/dist/index.d.ts +16 -0
- package/tokens/dist/index.js +16 -0
- package/tokens/dist/manifest.json +8 -0
- package/tokens/dist/tokens.css +6 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { validateSnapPoints } from './gesture-sheet-model.js';
|
|
3
|
+
import { useEffect, useRef, useCallback, useImperativeHandle, useMemo } from 'react';
|
|
3
4
|
import { AccessibilityInfo, BackHandler, findNodeHandle, Platform, View } from 'react-native';
|
|
4
5
|
import BottomSheet, { BottomSheetModal, BottomSheetScrollView, BottomSheetBackdrop, BottomSheetView } from '@gorhom/bottom-sheet';
|
|
5
6
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
@@ -10,10 +11,12 @@ import { Raised, useColors, useHIG } from './provider.js';
|
|
|
10
11
|
import { Heading, Text, Stack } from './surface.js';
|
|
11
12
|
import { Button } from './button.js';
|
|
12
13
|
/** Optional backend: host supplies GestureHandlerRootView, SafeAreaProvider and BottomSheetModalProvider. */
|
|
13
|
-
export function GestureSheet({ open, onOpenChange, title, description, children, contentMode = 'default', titleRef, presentation = 'modal', sheetRef, snapPoints, enableDynamicSizing = false, maxDynamicContentSize, enableContentPanningGesture, keyboardBehavior = 'interactive', keyboardBlurBehavior = 'restore', android_keyboardInputMode = 'adjustResize', initialIndex = 0, dismissible = true, returnFocusRef, closeLabel, onDismiss, onChange, onHardwareBackPress, topInset, bottomInset, modalRef, handleComponent, handleStyle, handleIndicatorStyle, backgroundComponent, backgroundStyle, containerStyle, animateOnMount, animationConfigs, backdropComponent }) {
|
|
14
|
+
export function GestureSheet({ open, onOpenChange, title, description, children, contentMode = 'default', raised = true, titleRef, presentation = 'modal', sheetRef, snapPoints, enableDynamicSizing = false, maxDynamicContentSize, enableContentPanningGesture, keyboardBehavior = 'interactive', keyboardBlurBehavior = 'restore', android_keyboardInputMode = 'adjustResize', initialIndex = 0, dismissible = true, returnFocusRef, closeLabel, onDismiss, onChange, onHardwareBackPress, topInset, bottomInset, modalRef, handleComponent, handleStyle, handleIndicatorStyle, backgroundComponent, backgroundStyle, containerStyle, animateOnMount, animationConfigs, backdropComponent, labelledBy }) {
|
|
14
15
|
if (enableDynamicSizing && snapPoints !== undefined)
|
|
15
16
|
throw new Error('Content-sized GestureSheet does not accept fixed snapPoints.');
|
|
16
17
|
const fixedSnapPoints = snapPoints ?? [];
|
|
18
|
+
if (!enableDynamicSizing)
|
|
19
|
+
validateSnapPoints(fixedSnapPoints, initialIndex);
|
|
17
20
|
if (!enableDynamicSizing && fixedSnapPoints.length === 0)
|
|
18
21
|
throw new Error('GestureSheet requires at least one snap point.');
|
|
19
22
|
if (maxDynamicContentSize !== undefined && (!Number.isFinite(maxDynamicContentSize) || maxDynamicContentSize <= 0))
|
|
@@ -26,6 +29,7 @@ export function GestureSheet({ open, onOpenChange, title, description, children,
|
|
|
26
29
|
const startingIndex = Math.max(0, Math.min(initialIndex, detentCount - 1));
|
|
27
30
|
const activeIndex = useRef(startingIndex), detentFrame = useRef(null), pendingSnap = useRef(false);
|
|
28
31
|
const detentKey = JSON.stringify(fixedSnapPoints);
|
|
32
|
+
const backendSnapPoints = useMemo(() => [...fixedSnapPoints], [detentKey]);
|
|
29
33
|
const latest = useRef({ open, onOpenChange, returnFocusRef, onDismiss, onHardwareBackPress });
|
|
30
34
|
latest.current = { open, onOpenChange, returnFocusRef, onDismiss, onHardwareBackPress };
|
|
31
35
|
const env = useHIG(), colors = useColors(), insets = useSafeAreaInsets();
|
|
@@ -141,13 +145,16 @@ export function GestureSheet({ open, onOpenChange, title, description, children,
|
|
|
141
145
|
} });
|
|
142
146
|
}, [focus, presentation, requestClose]);
|
|
143
147
|
const inlineAccessibility = presentation === 'inline' ? { accessibilityElementsHidden: !open, importantForAccessibility: open ? 'auto' : 'no-hide-descendants', pointerEvents: open ? 'auto' : 'none' } : {};
|
|
144
|
-
const contentAccessibility = { ...inlineAccessibility, ...(presentation === 'modal' && { accessibilityViewIsModal: true, onAccessibilityEscape: requestClose }) };
|
|
148
|
+
const contentAccessibility = { ...inlineAccessibility, ...(presentation === 'modal' && { accessibilityViewIsModal: true, onAccessibilityEscape: requestClose }), ...(labelledBy ? { accessibilityLabelledBy: labelledBy } : {}) };
|
|
145
149
|
const content = contentMode === 'custom' ? _jsxs(CustomContent, { ...contentAccessibility, accessible: false, collapsable: false, style: { ...(!enableDynamicSizing && { flex: 1, flexShrink: 1, minHeight: 0 }), direction: env.direction }, children: [!titleRef && _jsx(Heading, { ref: heading, accessible: true, accessibilityLabel: title, style: { position: 'absolute', width: 1, height: 1, overflow: 'hidden' }, children: title }), children] }) : _jsx(BottomSheetScrollView, { ...contentAccessibility, accessible: false, keyboardShouldPersistTaps: 'handled', contentContainerStyle: { padding: tokens.space.xl, paddingBottom: tokens.space.xl + (bottomInset ?? insets.bottom) }, children: _jsxs(Stack, { children: [_jsx(Heading, { ref: heading, children: title }), description && _jsx(Text, { children: description }), children, _jsx(Button, { intent: 'secondary', onPress: requestClose, children: closeLabel ?? env.messages.close ?? en.close })] }) });
|
|
146
150
|
// Expose individual children instead of grouping the sheet as one adjustable element. Gorhom forwards only
|
|
147
151
|
// basic accessibility props, so modal escape and VoiceOver scope belong on its measured or scrolling content.
|
|
148
152
|
// Inline content keeps its native state while closed, with all descendants hidden from accessibility.
|
|
149
153
|
// No stroke: the sheet is the `overlay` fill, darker than a card, lifted by a soft shadow.
|
|
150
|
-
const sheetFill = { backgroundColor: colors.overlay, borderRadius: tokens.radius.xl, boxShadow: '0 -8px 32px #0008' };
|
|
151
|
-
const
|
|
152
|
-
|
|
154
|
+
const sheetFill = useMemo(() => ({ backgroundColor: colors.overlay, borderRadius: tokens.radius.xl, boxShadow: '0 -8px 32px #0008' }), [colors.overlay]);
|
|
155
|
+
const sheetBackground = useMemo(() => backgroundStyle ? [sheetFill, backgroundStyle] : sheetFill, [sheetFill, backgroundStyle]);
|
|
156
|
+
const sheetIndicator = useMemo(() => { const fill = { backgroundColor: colors.action }; return handleIndicatorStyle ? [fill, handleIndicatorStyle] : fill; }, [colors.action, handleIndicatorStyle]);
|
|
157
|
+
const backendProps = { accessible: false, accessibilityLabel: title, index: presentation === 'inline' && !open ? -1 : presented.current ? Math.max(0, Math.min(activeIndex.current, detentCount - 1)) : startingIndex, snapPoints: enableDynamicSizing ? undefined : backendSnapPoints, enableDynamicSizing, maxDynamicContentSize: enableDynamicSizing ? maxDynamicContentSize : undefined, enableContentPanningGesture, enablePanDownToClose: dismissible, topInset: topInset ?? insets.top, bottomInset: bottomInset ?? insets.bottom, keyboardBehavior, keyboardBlurBehavior, android_keyboardInputMode, overrideReduceMotion: env.reducedMotion ? ReduceMotion.Always : ReduceMotion.System, animateOnMount, animationConfigs, backdropComponent: backdropComponent === undefined ? backdrop : backdropComponent, handleComponent, handleStyle, backgroundComponent, containerStyle, backgroundStyle: sheetBackground, handleIndicatorStyle: sheetIndicator, onChange: handleChange };
|
|
158
|
+
const lifted = raised ? _jsx(Raised, { children: content }) : content;
|
|
159
|
+
return presentation === 'inline' ? _jsx(BottomSheet, { ...backendProps, ref: inline, accessibilityElementsHidden: !open, importantForAccessibility: open ? 'auto' : 'no-hide-descendants', onClose: handleSettledClose, children: lifted }) : _jsx(BottomSheetModal, { ...backendProps, ref: sheet, enableDismissOnClose: true, stackBehavior: 'push', onDismiss: handleSettledClose, children: lifted });
|
|
153
160
|
}
|
package/native/dist/icons.d.ts
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/** Decorative shared symbols. The containing control or text carries the name. */
|
|
2
3
|
export declare function SearchIcon({ color }: {
|
|
3
4
|
color: string;
|
|
4
5
|
}): React.JSX.Element;
|
|
5
|
-
/** Points down; the caller rotates it. */
|
|
6
6
|
export declare function ChevronIcon({ color }: {
|
|
7
7
|
color: string;
|
|
8
8
|
}): React.JSX.Element;
|
|
9
|
-
/** A QR glyph: three finder squares and two cells. */
|
|
10
9
|
export declare function QrIcon({ color }: {
|
|
11
10
|
color: string;
|
|
12
11
|
}): React.JSX.Element;
|
|
13
12
|
export declare function CloseIcon({ color }: {
|
|
14
13
|
color: string;
|
|
15
14
|
}): React.JSX.Element;
|
|
16
|
-
/** A pencil: a slanted barrel over the line it writes on. */
|
|
17
15
|
export declare function EditIcon({ color }: {
|
|
18
16
|
color: string;
|
|
19
17
|
}): React.JSX.Element;
|
|
18
|
+
export declare function EmptyIcon({ color }: {
|
|
19
|
+
color: string;
|
|
20
|
+
}): React.JSX.Element;
|
|
21
|
+
export declare function EyeIcon({ color }: {
|
|
22
|
+
color: string;
|
|
23
|
+
}): React.JSX.Element;
|
|
20
24
|
export type SeverityIconKind = 'info' | 'success' | 'warning' | 'error';
|
|
21
|
-
/** Shape as well as colour tells the severities apart: warning is a diamond, the others a circle with their own mark. */
|
|
22
25
|
export declare function SeverityIcon({ kind, color }: {
|
|
23
26
|
kind: SeverityIconKind;
|
|
24
27
|
color: string;
|
|
25
28
|
}): React.JSX.Element;
|
|
26
|
-
|
|
27
|
-
export declare function EmptyIcon({ color }: {
|
|
29
|
+
export declare function TrendIcon({ color, direction }: {
|
|
28
30
|
color: string;
|
|
31
|
+
direction: 'up' | 'down';
|
|
29
32
|
}): React.JSX.Element;
|
package/native/dist/icons.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronDown } from '@bloxwap/icons/native/chevron-down';
|
|
3
|
+
import { CircleCheck } from '@bloxwap/icons/native/circle-check';
|
|
4
|
+
import { CircleX } from '@bloxwap/icons/native/circle-x';
|
|
5
|
+
import { Eye } from '@bloxwap/icons/native/eye';
|
|
6
|
+
import { Inbox } from '@bloxwap/icons/native/inbox';
|
|
7
|
+
import { Info } from '@bloxwap/icons/native/info';
|
|
8
|
+
import { PenLine } from '@bloxwap/icons/native/pen-line';
|
|
9
|
+
import { QrCode } from '@bloxwap/icons/native/qr-code';
|
|
10
|
+
import { Search } from '@bloxwap/icons/native/search';
|
|
11
|
+
import { TrendingDown } from '@bloxwap/icons/native/trending-down';
|
|
12
|
+
import { TrendingUp } from '@bloxwap/icons/native/trending-up';
|
|
13
|
+
import { TriangleAlert } from '@bloxwap/icons/native/triangle-alert';
|
|
14
|
+
import { X } from '@bloxwap/icons/native/x';
|
|
15
|
+
/** Decorative shared symbols. The containing control or text carries the name. */
|
|
16
|
+
export function SearchIcon({ color }) { return _jsx(Search, { size: 18, color: color }); }
|
|
17
|
+
export function ChevronIcon({ color }) { return _jsx(ChevronDown, { size: 20, color: color }); }
|
|
18
|
+
export function QrIcon({ color }) { return _jsx(QrCode, { size: 20, color: color }); }
|
|
19
|
+
export function CloseIcon({ color }) { return _jsx(X, { size: 20, color: color }); }
|
|
20
|
+
export function EditIcon({ color }) { return _jsx(PenLine, { size: 20, color: color }); }
|
|
21
|
+
export function EmptyIcon({ color }) { return _jsx(Inbox, { size: 48, color: color }); }
|
|
22
|
+
export function EyeIcon({ color }) { return _jsx(Eye, { size: 20, color: color }); }
|
|
23
|
+
const severitySymbols = { info: Info, success: CircleCheck, warning: TriangleAlert, error: CircleX };
|
|
24
|
+
export function SeverityIcon({ kind, color }) { const Symbol = severitySymbols[kind]; return _jsx(Symbol, { size: 20, color: color }); }
|
|
25
|
+
export function TrendIcon({ color, direction }) { const Symbol = direction === 'down' ? TrendingDown : TrendingUp; return _jsx(Symbol, { size: 20, color: color }); }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type ScrollViewProps } from 'react-native';
|
|
2
3
|
/** One language the host offers. */
|
|
3
4
|
export interface LanguageOption {
|
|
4
5
|
/** Stable id the host switches on, usually a BCP 47 tag such as `pt-BR`. */
|
|
@@ -27,9 +28,17 @@ export interface LanguageBlockProps {
|
|
|
27
28
|
disabled?: boolean;
|
|
28
29
|
/** A muted line under the header that explains the screen: Choose the language used throughout the app. */
|
|
29
30
|
description?: string;
|
|
31
|
+
/** Keeps the header pinned while the rest scrolls: the block becomes its own scroll view with the header as its sticky first child, transparent at rest and filled once content scrolls under it. Place it in a bounded container, such as a sheet body. */
|
|
32
|
+
stickyHeader?: boolean;
|
|
33
|
+
/** With `stickyHeader`: the header's fill once content is under it. Defaults to the background role; in a sheet pass the sheet's fill. */
|
|
34
|
+
stickyHeaderBackground?: string;
|
|
35
|
+
/** The scroll view used with `stickyHeader`, such as a sheet library's own. Defaults to React Native's ScrollView. */
|
|
36
|
+
scrollComponent?: React.ComponentType<ScrollViewProps>;
|
|
37
|
+
/** `nativeID` of the title, so a sheet around the block can name itself with `accessibilityLabelledBy` (Android). */
|
|
38
|
+
headingId?: string;
|
|
30
39
|
testID?: string;
|
|
31
40
|
}
|
|
32
41
|
/** The languages whose name, description or code contains the query, ignoring case and accents. An empty query keeps every language, in the host's order. */
|
|
33
42
|
export declare function filterLanguages(languages: readonly LanguageOption[], query: string): LanguageOption[];
|
|
34
43
|
/** Choose the app's language as one screen: a header, a search field, then each language as a row with its flag, its own name over the reader's name for it, and a check on the one in use. */
|
|
35
|
-
export declare function LanguageBlock({ title, onBack, headerAction, languages, value, onSelect, search, disabled, description, testID }: LanguageBlockProps): React.JSX.Element;
|
|
44
|
+
export declare function LanguageBlock({ title, onBack, headerAction, languages, value, onSelect, search, disabled, description, stickyHeader, stickyHeaderBackground, scrollComponent, headingId, testID }: LanguageBlockProps): React.JSX.Element;
|
|
@@ -1,6 +1,8 @@
|
|
|
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
|
+
import { Check } from '@bloxwap/icons/native/check';
|
|
2
3
|
import { useMemo, useState } from 'react';
|
|
3
4
|
import { Image, Pressable, View } from 'react-native';
|
|
5
|
+
import { StickyHeaderLayout } from './sticky-header.js';
|
|
4
6
|
import { useColors, useFills, useHIG, useMessages } from './provider.js';
|
|
5
7
|
import { Text } from './surface.js';
|
|
6
8
|
import { IconButton } from './button.js';
|
|
@@ -15,16 +17,21 @@ export function filterLanguages(languages, query) {
|
|
|
15
17
|
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
16
18
|
const avatar = 40;
|
|
17
19
|
/** Choose the app's language as one screen: a header, a search field, then each language as a row with its flag, its own name over the reader's name for it, and a check on the one in use. */
|
|
18
|
-
export function LanguageBlock({ title, onBack, headerAction, languages, value = null, onSelect, search = true, disabled, description, testID }) {
|
|
20
|
+
export function LanguageBlock({ title, onBack, headerAction, languages, value = null, onSelect, search = true, disabled, description, stickyHeader, stickyHeaderBackground, scrollComponent, headingId, testID }) {
|
|
19
21
|
const colors = useColors(), fills = useFills(), t = useMessages(), { direction } = useHIG();
|
|
20
22
|
const [query, setQuery] = useState('');
|
|
21
23
|
const rows = useMemo(() => filterLanguages(languages, query), [languages, query]);
|
|
22
24
|
const heading = title ?? t.language;
|
|
23
25
|
const shape = { width: avatar, height: avatar, borderRadius: avatar / 2, backgroundColor: fills.raised, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' };
|
|
24
26
|
const row = (pressed) => ({ flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 56, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 28, backgroundColor: pressed ? fills.well : 'transparent' });
|
|
25
|
-
|
|
27
|
+
const header = _jsxs(View, { style: stickyHeader ? { direction, flexDirection: 'row', alignItems: 'center', minHeight: 44 } : { flexDirection: 'row', alignItems: 'center', minHeight: 44 }, children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onBack ? _jsx(IconButton, { intent: 'ghost', label: t.back, suppressFeedback: true, testID: testID ? `${testID}-back` : undefined, onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: testID ? `${testID}-title` : undefined, nativeID: headingId, accessibilityRole: 'header', numberOfLines: 1, style: { flex: 1, textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: colors.text }, children: heading }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: headerAction })] });
|
|
28
|
+
const body = _jsxs(_Fragment, { children: [description ? _jsx(Text, { testID: testID ? `${testID}-description` : undefined, style: { paddingHorizontal: 4, fontSize: 14, lineHeight: 21, color: colors.muted }, children: description }) : null, search ? _jsx(SearchInput, { testID: testID ? `${testID}-search` : undefined, accessibilityLabel: t.searchLanguages, placeholder: t.searchLanguages, value: query, onChangeText: setQuery, returnKeyType: 'search', autoCapitalize: 'none', autoCorrect: false, spellCheck: false }) : null, rows.length === 0 ? _jsx(Text, { testID: testID ? `${testID}-empty` : undefined, accessibilityLiveRegion: 'polite', style: { paddingVertical: 32, textAlign: 'center', fontSize: 14, lineHeight: 20, color: colors.muted }, children: t.noResults }) :
|
|
26
29
|
_jsx(View, { testID: testID ? `${testID}-list` : undefined, accessibilityRole: 'radiogroup', accessibilityLabel: heading, style: { gap: 4 }, children: rows.map(language => {
|
|
27
30
|
const selected = language.code === value;
|
|
28
|
-
return _jsxs(Pressable, { testID: testID ? `${testID}-${language.code}` : undefined, accessibilityRole: 'radio', accessibilityState: disabled ? { checked: selected, disabled: true } : { checked: selected }, accessibilityLabel: [language.name, language.description].filter(Boolean).join(', '), accessibilityLanguage: language.code, disabled: disabled, onPress: () => onSelect(language), style: disabled ? ({ pressed }) => ({ ...row(pressed), opacity: 0.5 }) : ({ pressed }) => row(pressed), children: [_jsx(View, { ...hidden, children: typeof language.flag === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: language.flag }, style: shape }) : _jsx(View, { style: shape, children: language.flag ?? _jsx(Text, { accessible: false, maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: language.code.slice(0, 2).toUpperCase() }) }) }), _jsxs(View, { ...hidden, style: { flex: 1, flexShrink: 1, minWidth: 0 }, children: [_jsx(Text, { style: { fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.text }, children: language.name }), language.description ? _jsx(Text, { style: { fontSize: 14, lineHeight: 20, color: colors.muted }, children: language.description }) : null] }), selected ? _jsx(
|
|
31
|
+
return _jsxs(Pressable, { testID: testID ? `${testID}-${language.code}` : undefined, accessibilityRole: 'radio', accessibilityState: disabled ? { checked: selected, disabled: true } : { checked: selected }, accessibilityLabel: [language.name, language.description].filter(Boolean).join(', '), accessibilityLanguage: language.code, disabled: disabled, onPress: () => onSelect(language), style: disabled ? ({ pressed }) => ({ ...row(pressed), opacity: 0.5 }) : ({ pressed }) => row(pressed), children: [_jsx(View, { ...hidden, children: typeof language.flag === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: language.flag }, style: shape }) : _jsx(View, { style: shape, children: language.flag ?? _jsx(Text, { accessible: false, maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: language.code.slice(0, 2).toUpperCase() }) }) }), _jsxs(View, { ...hidden, style: { flex: 1, flexShrink: 1, minWidth: 0 }, children: [_jsx(Text, { style: { fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.text }, children: language.name }), language.description ? _jsx(Text, { style: { fontSize: 14, lineHeight: 20, color: colors.muted }, children: language.description }) : null] }), selected ? _jsx(Check, { size: 20, color: colors.text, testID: testID ? `${testID}-check` : undefined }) : null] }, language.code);
|
|
29
32
|
}) })] });
|
|
33
|
+
// The sticky layout puts the header and the body in separate views, so the body's first gap is its top padding.
|
|
34
|
+
if (stickyHeader)
|
|
35
|
+
return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: testID ? `${testID}-sticky-header` : 'language-sticky-header', header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, bodyStyle: { direction, gap: 16, paddingTop: 16 }, children: body });
|
|
36
|
+
return _jsxs(View, { testID: testID, style: { direction, padding: 16, gap: 16 }, children: [header, body] });
|
|
30
37
|
}
|
|
@@ -24,8 +24,10 @@ export interface ListGroupProps {
|
|
|
24
24
|
export declare function ListGroup({ title, titleAccessory, action, intro, children, testID }: ListGroupProps): React.JSX.Element;
|
|
25
25
|
export interface ListRowProps extends Omit<PressableProps, 'children' | 'style' | 'onPress' | 'disabled' | 'role' | 'accessibilityRole' | 'accessibilityLabel' | 'accessibilityState' | 'aria-label' | 'aria-checked' | 'aria-disabled' | 'aria-busy' | 'aria-selected'> {
|
|
26
26
|
label: string;
|
|
27
|
-
/** A muted second line under the label, such as a subtitle or an address. The row grows to fit it, and it is read with the label (as the hint of a switch row). */
|
|
27
|
+
/** A muted second line under the label, such as a subtitle or an address. The row grows to fit it, and it is read with the label (as the hint of a switch row). A string, a number, one Text element, or a fragment or array with bare text among its children (`<>Ends in <Text>3m</Text></>`) is drawn in the muted Text; any other node (several Text elements, a row with an icon, a live figure) is drawn as given in a View, styled by the host. A component of the host's own that renders bare strings must be wrapped in a Text, as anywhere in a View. Its text is read as concatenated, so give such a row `accessibilityLabel`. */
|
|
28
28
|
description?: React.ReactNode;
|
|
29
|
+
/** What the row reads as, in place of its label, description and value: Long BTC, 10×, 0.5 BTC, up $12. A pressable row keeps its busy text after it, a switch row is named by it (its description and value stay its hint), and a static row becomes one element named by it (with a `trailing` control, the label, description and value become that element and the control stays its own target). */
|
|
30
|
+
accessibilityLabel?: string;
|
|
29
31
|
/** Colours the label: `destructive` for an action that deletes or ends something, `muted` for one that is done or inactive. */
|
|
30
32
|
tone?: 'destructive' | 'muted';
|
|
31
33
|
/** Artwork before the label, such as an icon. Decorative: the label names the row. */
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check as SharedCheck } from '@bloxwap/icons/native/check';
|
|
3
|
+
import { ArrowUpRight } from '@bloxwap/icons/native/arrow-up-right';
|
|
2
4
|
import React, { forwardRef, useState } from 'react';
|
|
3
|
-
import { ActivityIndicator, Platform, Pressable, View } from 'react-native';
|
|
5
|
+
import { ActivityIndicator, Platform, Pressable, Text as NativeText, View } from 'react-native';
|
|
4
6
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
7
|
import { useColors, useFills, useHIG } from './provider.js';
|
|
6
8
|
import { Text } from './surface.js';
|
|
@@ -8,6 +10,9 @@ import { ChevronIcon } from './icons.js';
|
|
|
8
10
|
import { SwitchRow } from './switch-row.js';
|
|
9
11
|
import { plainText } from './text-content.js';
|
|
10
12
|
const shown = (node) => node != null && node !== false && node !== '';
|
|
13
|
+
const bare = (node) => typeof node === 'string' || typeof node === 'number';
|
|
14
|
+
/** A fragment or array with a bare string or number among its children (through nested fragments and arrays). */
|
|
15
|
+
const loose = (node) => Array.isArray(node) ? node.some(child => bare(child) || loose(child)) : React.isValidElement(node) && node.type === React.Fragment && loose([].concat(node.props.children));
|
|
11
16
|
const actionSlop = { top: 12, bottom: 12, left: 8, right: 8 };
|
|
12
17
|
/** A grouped list for menus and settings: an optional heading over rows that share one rounded container. */
|
|
13
18
|
export function ListGroup({ title, titleAccessory, action, intro, children, testID }) {
|
|
@@ -32,33 +37,41 @@ export function ListGroup({ title, titleAccessory, action, intro, children, test
|
|
|
32
37
|
}
|
|
33
38
|
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
34
39
|
/** The check of a selected row. It does not mirror in right-to-left layouts. */
|
|
35
|
-
function Check({ color, testID }) { return _jsx(
|
|
40
|
+
function Check({ color, testID }) { return _jsx(SharedCheck, { size: 20, color: color, testID: testID }); }
|
|
36
41
|
/** An arrow pointing up and away, for a row that opens something outside the app; it mirrors in right-to-left layouts. */
|
|
37
|
-
function External({ color, rtl, testID }) {
|
|
38
|
-
return _jsxs(View, { ...hidden, testID: testID, style: { width: 20, height: 20, alignItems: 'center', justifyContent: 'center', transform: rtl ? [{ scaleX: -1 }] : undefined }, children: [_jsx(View, { style: { position: 'absolute', width: 12, height: 1.75, borderRadius: 1, backgroundColor: color, transform: [{ rotate: '-45deg' }] } }), _jsx(View, { style: { position: 'absolute', top: 5, right: 5, width: 7, height: 7, borderTopWidth: 1.75, borderRightWidth: 1.75, borderColor: color } })] });
|
|
39
|
-
}
|
|
42
|
+
function External({ color, rtl, testID }) { return _jsx(ArrowUpRight, { size: 20, color: color, testID: testID, style: { transform: rtl ? [{ scaleX: -1 }] : undefined } }); }
|
|
40
43
|
/** One row of a ListGroup: the label leads; a value, icons, a badge or a control trail. With `onSelect` the whole row is one button and shows a disclosure chevron; with `checked` or `onCheckedChange` the whole row is a switch; otherwise the row is static, so a control in `trailing` is its only target. Other Pressable props, such as `android_disableSound`, `hitSlop` or `onLongPress`, reach the row, and the ref reaches its view. */
|
|
41
|
-
export const ListRow = /* @__PURE__ */ forwardRef(function ListRow({ label, description, tone, leading, value, valueLabel, valueTone, trailing, onSelect, disabled, selected, busy, busyLabel, disclosure, checked, defaultChecked, onCheckedChange, testID, ...rest }, ref) {
|
|
44
|
+
export const ListRow = /* @__PURE__ */ forwardRef(function ListRow({ label, description, accessibilityLabel, tone, leading, value, valueLabel, valueTone, trailing, onSelect, disabled, selected, busy, busyLabel, disclosure, checked, defaultChecked, onCheckedChange, testID, ...rest }, ref) {
|
|
42
45
|
const colors = useColors(), fills = useFills(), { direction, messages } = useHIG();
|
|
43
46
|
const [internal, setInternal] = useState(!!defaultChecked);
|
|
44
47
|
const toggles = !onSelect && (checked !== undefined || defaultChecked !== undefined || onCheckedChange != null);
|
|
45
48
|
const row = (pressed) => ({ flexDirection: 'row', alignItems: 'flex-start', gap: 12, minHeight: 56, paddingVertical: 8, paddingHorizontal: 20, backgroundColor: pressed ? fills.raised : fills.well, opacity: disabled ? 0.5 : 1 });
|
|
46
49
|
const text = typeof value === 'string' || typeof value === 'number';
|
|
47
50
|
const described = shown(description), about = described ? plainText(description) : '';
|
|
48
|
-
const reading = [label, about || null, text ? String(value) : valueLabel ?? null].filter(Boolean).join(', ');
|
|
51
|
+
const reading = accessibilityLabel ?? [label, about || null, text ? String(value) : valueLabel ?? null].filter(Boolean).join(', ');
|
|
49
52
|
const busyText = busyLabel ?? messages.busy ?? en.busy;
|
|
50
53
|
const spoken = busy && busyText && Platform.OS !== 'android' ? `${reading} · ${busyText}` : reading;
|
|
51
54
|
// Everything aligns to the first line of the label, so a trailing switch stays at the top when the label wraps.
|
|
52
55
|
const first = { minHeight: 40, justifyContent: 'center' };
|
|
53
56
|
// A static row with a state is one element, so the state is read; a trailing control keeps the row open so the control stays its own target.
|
|
54
|
-
|
|
55
|
-
const
|
|
57
|
+
// A host name on a static row: with no trailing control the row is one element; with one, the text is one element beside it.
|
|
58
|
+
const named = !onSelect && !toggles && accessibilityLabel !== undefined;
|
|
59
|
+
const announced = !onSelect && !toggles && (selected !== undefined || !!busy || named) && trailing == null;
|
|
60
|
+
const grouped = named && trailing != null;
|
|
61
|
+
const quiet = onSelect || toggles || announced ? hidden : {}, textQuiet = grouped ? hidden : quiet;
|
|
56
62
|
const lead = leading == null ? null : _jsx(View, { ...hidden, style: first, children: leading });
|
|
57
63
|
const labelColor = tone === 'destructive' ? colors.negative : tone === 'muted' ? colors.muted : colors.text;
|
|
64
|
+
const descriptionStyle = { fontSize: 14, lineHeight: 20, color: colors.muted };
|
|
65
|
+
// Text, one Text element, or a fragment or array holding bare text (`<>Ends in <Text>3m</Text></>`) keeps the muted line, since a bare string cannot sit in a View; richer host content is laid out as given.
|
|
66
|
+
const inline = bare(description) || loose(description) || (React.isValidElement(description) && (description.type === Text || description.type === NativeText));
|
|
67
|
+
const descriptionTestID = testID ? `${testID}-description` : undefined;
|
|
68
|
+
const nameBox = { flex: 1, flexShrink: 1, minWidth: 0, paddingVertical: 8 };
|
|
69
|
+
const nameRole = grouped ? { accessible: true, accessibilityLabel } : quiet;
|
|
58
70
|
const name = described
|
|
59
|
-
? _jsxs(View, { ...
|
|
60
|
-
: _jsx(
|
|
61
|
-
|
|
71
|
+
? _jsxs(View, { ...nameRole, style: nameBox, children: [_jsx(Text, { style: { fontSize: 16, lineHeight: 24, color: labelColor }, children: label }), inline ? _jsx(Text, { testID: descriptionTestID, style: descriptionStyle, children: description }) : _jsx(View, { testID: descriptionTestID, style: { minWidth: 0 }, children: description })] })
|
|
72
|
+
: grouped ? _jsx(View, { ...nameRole, style: nameBox, children: _jsx(Text, { style: { fontSize: 16, lineHeight: 24, color: labelColor }, children: label }) })
|
|
73
|
+
: _jsx(Text, { ...textQuiet, style: { ...nameBox, fontSize: 16, lineHeight: 24, color: labelColor }, children: label });
|
|
74
|
+
const amount = value == null || value === false ? null : text ? _jsx(Text, { ...textQuiet, testID: testID ? `${testID}-value` : undefined, numberOfLines: 1, style: { flexShrink: 1, maxWidth: '50%', paddingVertical: 8, fontSize: 16, lineHeight: 24, color: colors[valueTone ?? 'muted'], textAlign: 'right' }, children: value }) : _jsx(View, { ...(grouped ? hidden : !onSelect && !toggles && !announced && valueLabel ? { accessible: true, accessibilityLabel: valueLabel } : {}), style: first, children: value });
|
|
62
75
|
const extra = trailing == null ? null : _jsx(View, { pointerEvents: onSelect || toggles ? 'none' : 'auto', ...quiet, style: { flexDirection: 'row', alignItems: 'center', gap: 8, minHeight: 40 }, children: trailing });
|
|
63
76
|
const chevron = _jsx(View, { testID: testID ? `${testID}-chevron` : undefined, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) });
|
|
64
77
|
const glyphKind = disclosure ?? (selected !== undefined ? 'none' : 'chevron');
|
|
@@ -70,7 +83,7 @@ export const ListRow = /* @__PURE__ */ forwardRef(function ListRow({ label, desc
|
|
|
70
83
|
const on = checked ?? internal;
|
|
71
84
|
const hint = [about || null, text ? String(value) : valueLabel ?? null].filter(Boolean).join(', ') || undefined;
|
|
72
85
|
// The row holds an uncontrolled state itself so the drawn track follows it; SwitchRow stays controlled and emits feedback once.
|
|
73
|
-
return _jsx(SwitchRow, { ...rest, ref: ref, testID: testID, label: label, accessibilityHint: rest.accessibilityHint ?? hint, accessibilityState: busy ? { busy: true } : undefined, checked: on, disabled: disabled || busy, onCheckedChange: next => { if (checked === undefined)
|
|
86
|
+
return _jsx(SwitchRow, { ...rest, ref: ref, testID: testID, label: accessibilityLabel ?? label, accessibilityHint: rest.accessibilityHint ?? hint, accessibilityState: busy ? { busy: true } : undefined, checked: on, disabled: disabled || busy, onCheckedChange: next => { if (checked === undefined)
|
|
74
87
|
setInternal(next); onCheckedChange?.(next); }, style: row(false), children: _jsx(SwitchRowContent, { first: first, lead: lead, name: name, amount: amount, extra: extra, checked: on, testID: testID }) });
|
|
75
88
|
}
|
|
76
89
|
const state = { ...(selected !== undefined ? { selected } : {}), ...(busy ? { busy: true } : {}) };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type ScrollViewProps } from 'react-native';
|
|
2
3
|
import { type Figure } from './figure.js';
|
|
3
4
|
import type { AssetArtwork } from './asset-balance-row.js';
|
|
4
5
|
export type { AssetArtwork } from './asset-balance-row.js';
|
|
@@ -77,6 +78,12 @@ export interface ManagePositionBlockProps {
|
|
|
77
78
|
headerAction?: React.ReactNode;
|
|
78
79
|
/** Sets `nativeID` on the title, so a sheet around the pane can name itself with `accessibilityLabelledBy` (Android). */
|
|
79
80
|
headingId?: string;
|
|
81
|
+
/** Keeps the header pinned while the rest scrolls: the block becomes its own scroll view with the header as its sticky first child, transparent at rest and filled once content scrolls under it. Place it in a bounded container, such as a sheet body. */
|
|
82
|
+
stickyHeader?: boolean;
|
|
83
|
+
/** With `stickyHeader`: the header's fill once content is under it. Defaults to the background role; in a sheet pass the sheet's fill. */
|
|
84
|
+
stickyHeaderBackground?: string;
|
|
85
|
+
/** The scroll view used with `stickyHeader`, such as a sheet library's own. Defaults to React Native's ScrollView. */
|
|
86
|
+
scrollComponent?: React.ComponentType<ScrollViewProps>;
|
|
80
87
|
testID?: string;
|
|
81
88
|
}
|
|
82
89
|
/** Distance left before liquidation. `total` is the span from entry to liquidation, `buffer` how much of it remains between mark and liquidation (the whole span while in profit), `drawdown` the rest, and `share` the buffer as a fraction of the span. Unknown mark or liquidation, or a liquidation on the wrong side of entry, gives zeros and a `null` share. */
|
|
@@ -92,4 +99,4 @@ export declare function positionCorridor({ side, entry, mark, liquidation }: {
|
|
|
92
99
|
share: number | null;
|
|
93
100
|
};
|
|
94
101
|
/** One open position as a screen: margin and notional under the share left before liquidation, then the liquidation, mark and entry prices as a `BarPnl`, what can be done, and the position itself. Both bars are drawn without a card, because nothing in them can be pressed. */
|
|
95
|
-
export declare function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, testID }: ManagePositionBlockProps): React.JSX.Element;
|
|
102
|
+
export declare function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, stickyHeader, stickyHeaderBackground, scrollComponent, testID }: ManagePositionBlockProps): React.JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { Image, Pressable, View } from 'react-native';
|
|
4
|
+
import { StickyHeaderLayout } from './sticky-header.js';
|
|
4
5
|
import { useColors, useFills, useHIG, useMessages, useNumberLocale, usePresentNumber } from './provider.js';
|
|
5
6
|
import { Text } from './surface.js';
|
|
6
7
|
import { IconButton } from './button.js';
|
|
@@ -38,7 +39,7 @@ function Sentence({ template, text, value, options, suffix, testID }) {
|
|
|
38
39
|
return _jsxs(View, { accessible: true, accessibilityLabel: reading, testID: testID, style: { direction, flexDirection: 'row', alignItems: 'center', flexShrink: 1 }, children: [parts[0] ? _jsx(Text, { accessible: false, style: words, children: parts[0] }) : null, _jsx(AnimatedNumberReadout, { value: value, options: options, suffix: suffix, tone: 'muted', style: type }), parts[1] ? _jsx(Text, { accessible: false, style: words, children: parts[1] }) : null] });
|
|
39
40
|
}
|
|
40
41
|
/** One open position as a screen: margin and notional under the share left before liquidation, then the liquidation, mark and entry prices as a `BarPnl`, what can be done, and the position itself. Both bars are drawn without a card, because nothing in them can be pressed. */
|
|
41
|
-
export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, testID }) {
|
|
42
|
+
export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, stickyHeader, stickyHeaderBackground, scrollComponent, testID }) {
|
|
42
43
|
const colors = useColors(), fills = useFills(), t = useMessages(), { direction } = useHIG(), locale = useNumberLocale(), present = usePresentNumber();
|
|
43
44
|
// The artwork that failed to draw (its URL, or the position for a host element); it then shows the fallback or the initials until the artwork changes.
|
|
44
45
|
const [broken, setBroken] = useState(null);
|
|
@@ -78,5 +79,9 @@ export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidati
|
|
|
78
79
|
return { value: figure, valueTone: action.tone };
|
|
79
80
|
return { value: _jsx(AnimatedNumberReadout, { ...figureProps(figure), tone: action.tone ?? 'muted', testID: `manage-action-${action.id}-value`, style: { fontSize: 16, lineHeight: 24 } }), valueLabel: figureReading(figure, locale, present(figure.options)) };
|
|
80
81
|
};
|
|
81
|
-
|
|
82
|
+
const header = _jsxs(View, { testID: 'manage-header', style: { flexDirection: 'row', alignItems: 'center', minHeight: 44 }, children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onBack ? _jsx(IconButton, { intent: 'ghost', label: t.back, suppressFeedback: true, testID: 'manage-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'manage-title', nativeID: headingId, accessibilityRole: 'header', numberOfLines: 1, style: { flex: 1, textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: colors.text }, children: labels.title }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: headerAction })] });
|
|
83
|
+
const body = _jsxs(_Fragment, { children: [_jsxs(View, { style: { gap: 20, marginTop: 16, paddingHorizontal: 4 }, children: [_jsx(BarMark, { testID: 'manage-margin', surface: false, title: mode ?? labels.margin, elements: marginBar, description: _jsx(Sentence, { testID: 'manage-to-liquidation', template: labels.toLiquidation, text: left === null ? unknown : formatNumberReadout(left, locale, tenth).text + percent, value: left, options: tenth, suffix: percent }) }), _jsx(BarPnl, { testID: 'manage-liquidation', surface: false, compact: true, side: side, entry: entry, mark: mark, liquidation: liquidation, labels: { liquidation: labels.liquidation, mark: labels.mark, entry: labels.entry }, priceOptions: priceOptions })] }), actions.length > 0 ? _jsx(View, { testID: 'manage-actions', style: { marginTop: 16 }, children: _jsx(ListGroup, { children: actions.map(action => _jsx(ListRow, { testID: `manage-action-${action.id}`, label: action.label, disabled: action.disabled, onSelect: action.onSelect, ...actionValue(action) }, action.id)) }) }) : null, row()] });
|
|
84
|
+
if (stickyHeader)
|
|
85
|
+
return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: 'manage-sticky-header', header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: body });
|
|
86
|
+
return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [header, body] });
|
|
82
87
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check } from '@bloxwap/icons/native/check';
|
|
2
3
|
import { forwardRef } from 'react';
|
|
3
4
|
import { View } from 'react-native';
|
|
4
5
|
import { useColors, useFills } from './provider.js';
|
|
@@ -11,20 +12,30 @@ const hidden = { accessible: false, accessibilityElementsHidden: true, important
|
|
|
11
12
|
export const MarketRow = /* @__PURE__ */ forwardRef(function MarketRow({ symbol, name, price, change, priceOptions, changeOptions, mode = 'action', onSelect, identity, icon, favorite, volume, detail, trailing, selected, disabled, active, onPressIn, testID, style }, ref) {
|
|
12
13
|
const colors = useColors(), fills = useFills();
|
|
13
14
|
const label = `${name} (${symbol})`;
|
|
14
|
-
|
|
15
|
+
// A row with host options is one line: the name and its detail truncate rather than wrap, so the trailing cells keep their place.
|
|
16
|
+
const lines = detail === undefined ? null : _jsxs(View, { style: { alignItems: 'flex-start', flexShrink: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { fontSize: 16, lineHeight: 24, fontWeight: '600', color: disabled ? colors.muted : colors.text }, children: label }), typeof detail === 'string' || typeof detail === 'number' ? _jsx(Text, { numberOfLines: 1, style: { fontSize: 14, lineHeight: 20, color: colors.muted }, children: detail }) : detail] });
|
|
15
17
|
const detailText = detail === undefined ? '' : plainText(detail);
|
|
18
|
+
// When the row is too narrow for everything, space is given up in this order (as on web): the name truncates down to a floor (the
|
|
19
|
+
// name cell's basis is 96dp and it never shrinks, so the icon never leaves the identity and the start of the name stays readable);
|
|
20
|
+
// then whole figures drop from the end (volume, change, price); then the trailing content is clipped. The check keeps its place.
|
|
21
|
+
const nameCell = { flexGrow: 1, flexShrink: 0, flexBasis: 96, minWidth: 0 };
|
|
16
22
|
const title = mode === 'presentation'
|
|
17
|
-
? _jsx(View, { style: disabled ? { opacity: 0.5,
|
|
18
|
-
: lines ? _jsx(Button, { intent: 'ghost', contentMode: 'custom', accessibilityLabel: detailText ? `${label}, ${detailText}` : label, accessibilityState: selected ? { selected: true } : undefined, disabled: disabled, onPress: onSelect, onPressIn: onPressIn, testID: testID ? `${testID}-select` : undefined, style: { alignItems: 'flex-start' }, children: lines })
|
|
19
|
-
: _jsx(Button, { intent: 'ghost', accessibilityState: selected ? { selected: true } : undefined, disabled: disabled, onPress: onSelect, onPressIn: onPressIn, testID: testID ? `${testID}-select` : undefined, children: label });
|
|
23
|
+
? _jsx(View, { style: disabled ? { opacity: 0.5, ...nameCell } : nameCell, children: identity ?? lines ?? _jsx(Text, { numberOfLines: 1, children: label }) })
|
|
24
|
+
: lines ? _jsx(Button, { intent: 'ghost', contentMode: 'custom', accessibilityLabel: detailText ? `${label}, ${detailText}` : label, accessibilityState: selected ? { selected: true } : undefined, disabled: disabled, onPress: onSelect, onPressIn: onPressIn, testID: testID ? `${testID}-select` : undefined, style: { alignItems: 'flex-start', ...nameCell, paddingVertical: 0 }, children: lines })
|
|
25
|
+
: _jsx(Button, { intent: 'ghost', contentMode: 'custom', accessibilityLabel: label, accessibilityState: selected ? { selected: true } : undefined, disabled: disabled, onPress: onSelect, onPressIn: onPressIn, testID: testID ? `${testID}-select` : undefined, style: { alignItems: 'flex-start', ...nameCell }, children: _jsx(Text, { numberOfLines: 1, style: { fontSize: 16, fontWeight: '600', color: disabled ? colors.faint : colors.muted }, children: label }) });
|
|
20
26
|
const leading = favorite !== undefined || icon !== undefined;
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
27
|
+
// The identity's basis is its favourite + icon + the name cell's 96dp, and it does not shrink: that is the floor.
|
|
28
|
+
const identityCell = _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: leading ? 8 : 0, flexGrow: 1, flexShrink: 0, flexBasis: 'auto' }, children: [favorite !== undefined ? _jsx(View, { style: { flexShrink: 0 }, children: favorite }) : null, icon !== undefined ? _jsx(View, { ...hidden, style: { flexShrink: 0 }, children: icon }) : null, title] });
|
|
29
|
+
const dim = disabled ? { opacity: 0.5 } : null;
|
|
30
|
+
// The figures are one 44dp line that wraps and clips, so a figure that does not fit moves to the hidden second line instead of being
|
|
31
|
+
// cut; the zero-width first item lets even the price wrap away. Their large shrink factor makes them give up space before the trailing content.
|
|
32
|
+
const figure = (node) => _jsx(View, { style: [{ height: 44, justifyContent: 'center', marginStart: 12, flexShrink: 0 }, dim], children: node });
|
|
33
|
+
const figures = price === undefined && change === undefined && volume === undefined ? null : _jsxs(View, { testID: testID ? `${testID}-figures` : undefined, style: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'flex-end', alignContent: 'flex-start', height: 44, overflow: 'hidden', flexGrow: 0, flexShrink: 1000, minWidth: 0, marginStart: -12 }, children: [_jsx(View, { style: { width: 0, height: 44 } }), price !== undefined ? figure(_jsx(Usd, { value: price, options: priceOptions })) : null, change !== undefined ? figure(_jsx(Percent, { value: change, options: changeOptions })) : null, volume !== undefined ? figure(volume) : null] });
|
|
34
|
+
const cells = _jsxs(_Fragment, { children: [identityCell, figures, trailing != null && trailing !== false ? _jsx(View, { testID: testID ? `${testID}-trailing` : undefined, style: [{ flexDirection: 'row', alignItems: 'center', gap: 8, flexShrink: 1, minWidth: 0, overflow: 'hidden' }, dim], children: trailing }) : null, selected ? _jsx(Check, { size: 20, color: colors.text, testID: testID ? `${testID}-check` : undefined }) : null] });
|
|
24
35
|
const plain = !ref && !leading && detail === undefined && price !== undefined && change !== undefined && volume === undefined && trailing == null && !selected && !disabled && !active && !onPressIn && mode === 'action' && !testID && !style;
|
|
25
36
|
// Without host options the row is exactly the 0.6.0 one: the name button, the price and the change in a wrapping Row.
|
|
26
37
|
if (plain)
|
|
27
38
|
return _jsxs(Row, { children: [_jsxs(Button, { intent: 'ghost', onPress: onSelect, children: [name, " (", symbol, ")"] }), _jsx(Usd, { value: price, options: priceOptions }), _jsx(Percent, { value: change, options: changeOptions })] });
|
|
28
39
|
const state = mode === 'presentation' && (selected || disabled) ? { ...(selected ? { selected: true } : {}), ...(disabled ? { disabled: true } : {}) } : undefined;
|
|
29
|
-
return _jsx(View, { ref: ref, testID: testID, accessibilityState: state, style: [{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', flexWrap: '
|
|
40
|
+
return _jsx(View, { ref: ref, testID: testID, accessibilityState: state, style: [{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', flexWrap: 'nowrap', gap: 12, paddingVertical: 8 }, active ? { backgroundColor: fills.well, borderRadius: 14 } : null, style], children: cells });
|
|
30
41
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { assertUniqueKeys, paginationValue } from '@bloxwap/hig/contracts';
|
|
2
3
|
import { useEffect, useRef, useState } from 'react';
|
|
3
4
|
import { Animated, Easing, Pressable, View } from 'react-native';
|
|
4
5
|
import { tokens } from '@bloxwap/hig/tokens';
|
|
5
6
|
import { ChevronIcon } from './icons.js';
|
|
6
|
-
import { formatNumber } from '
|
|
7
|
+
import { formatNumber } from './number-format.js';
|
|
7
8
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
8
9
|
import { useColors, useControllable, useFills, useHIG } from './provider.js';
|
|
9
10
|
import { Button } from './button.js';
|
|
@@ -11,7 +12,8 @@ import { Text, Inline, Stack, Surface } from './surface.js';
|
|
|
11
12
|
import { Field, SearchInput } from './field.js';
|
|
12
13
|
/** Actions that sit side by side are 8dp apart; content keeps the 12dp gap. */
|
|
13
14
|
const actionRow = { gap: tokens.space.sm };
|
|
14
|
-
export function Tabs({ label, items, value, defaultValue, onValueChange }) { const colors = useColors(); const fills = useFills(); const { direction } = useHIG(); const [
|
|
15
|
+
export function Tabs({ label, items, value, defaultValue, onValueChange }) { const colors = useColors(); const fills = useFills(); const { direction } = useHIG(); const [stored, set] = useControllable(value, defaultValue ?? items.find(item => !item.disabled)?.value ?? '', onValueChange); assertUniqueKeys(items, item => item.value, 'Tabs'); const controlled = useRef(value !== undefined).current; const current = items.some(item => item.value === stored && !item.disabled) ? stored : controlled ? '' : items.find(item => !item.disabled)?.value ?? ''; useEffect(() => { if (!controlled && stored !== current)
|
|
16
|
+
set(current); }, [controlled, stored, current]); return _jsxs(View, { style: { direction, gap: 12 }, children: [_jsx(Inline, { style: actionRow, accessibilityRole: 'tablist', accessibilityLabel: label, children: items.map(i => _jsx(Pressable, { accessibilityRole: 'tab', "aria-selected": current === i.value, "aria-disabled": !!i.disabled, accessibilityState: { selected: current === i.value, disabled: !!i.disabled }, disabled: i.disabled, onPress: () => { if (!i.disabled)
|
|
15
17
|
set(i.value); }, hitSlop: { top: 2, bottom: 2 }, style: ({ pressed }) => ({ minHeight: 44, paddingHorizontal: 20, paddingVertical: 10, borderRadius: 9999, alignItems: 'center', justifyContent: 'center', backgroundColor: current === i.value ? fills.raised : 'transparent', opacity: i.disabled ? .5 : pressed ? .85 : 1 }), children: _jsx(Text, { style: { fontWeight: '600', color: current === i.value ? colors.text : colors.muted }, children: i.label }) }, i.value)) }), items.find(i => i.value === current)?.content] }); }
|
|
16
18
|
/** A strokeless card. The outline chevron sits on the trailing edge and turns as the content expands or collapses; with reduced motion both change at once. */
|
|
17
19
|
export function Accordion({ title, children, open, onOpenChange }) {
|
|
@@ -53,6 +55,6 @@ export function Accordion({ title, children, open, onOpenChange }) {
|
|
|
53
55
|
}
|
|
54
56
|
export function Navigation({ label, items }) { const colors = useColors(); return _jsx(Stack, { accessibilityLabel: label, style: { gap: 4 }, children: items.map(i => _jsx(Button, { fullWidth: true, intent: 'ghost', accessibilityState: { selected: !!i.active }, onPress: i.onNavigate, style: { alignItems: 'flex-start', backgroundColor: i.active ? colors.nested : 'transparent' }, children: i.label }, i.id)) }); }
|
|
55
57
|
export const BottomNavigation = Navigation;
|
|
56
|
-
export function Pagination({ page, total, onPageChange }) { const { locale, messages } = useHIG(); return _jsxs(Inline, { style: actionRow, children: [_jsx(Button, { intent: 'secondary', disabled: page <= 1, onPress: () => onPageChange(page - 1), children: messages.previous ?? en.previous }), _jsx(Text, { children: (messages.pageOf ?? en.pageOf)(formatNumber(page, locale), formatNumber(total, locale)) }), _jsx(Button, { intent: 'secondary', disabled: page >= total, onPress: () => onPageChange(page + 1), children: messages.next ?? en.next })] }); }
|
|
58
|
+
export function Pagination({ page, total, onPageChange }) { ({ page, total } = paginationValue(page, total)); const { locale, messages } = useHIG(); return _jsxs(Inline, { style: actionRow, children: [_jsx(Button, { intent: 'secondary', disabled: page <= 1, onPress: () => onPageChange(page - 1), children: messages.previous ?? en.previous }), _jsx(Text, { children: (messages.pageOf ?? en.pageOf)(formatNumber(page, locale), formatNumber(total, locale)) }), _jsx(Button, { intent: 'secondary', disabled: page >= total, onPress: () => onPageChange(page + 1), children: messages.next ?? en.next })] }); }
|
|
57
59
|
export function Search({ query, onQueryChange, results, loading, error }) { const { locale, messages } = useHIG(); return _jsxs(Stack, { children: [_jsx(Field, { label: messages.search ?? en.search, children: _jsx(SearchInput, { value: query, onChangeText: onQueryChange }) }), _jsx(Text, { accessibilityLiveRegion: 'polite', children: loading ? messages.searching ?? en.searching : error ?? (results.length ? (messages.resultCount ?? en.resultCount)(results.length, locale) : messages.noResults ?? en.noResults) }), !loading && !error && results.map(r => _jsx(Button, { intent: 'ghost', onPress: r.onSelect, children: r.label }, r.id))] }); }
|
|
58
60
|
export function BackButton({ onBack }) { const { messages } = useHIG(); return _jsx(Button, { intent: 'secondary', onPress: onBack, children: messages.back ?? en.back }); }
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native number display. Hermes on iOS ignores `signDisplay` (`exceptZero` drew `12.34%` where Android drew `+12.34%`), so every
|
|
3
|
+
* native figure composes its sign in HIG's own code instead of asking Intl for it: iOS and Android draw the same string, and it is
|
|
4
|
+
* the string an Intl that honours `signDisplay` draws. Display only.
|
|
5
|
+
*/
|
|
6
|
+
export declare function formatNumber(value: number | null | undefined, locale?: string, options?: Intl.NumberFormatOptions): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { formatSignedNumber } from '@bloxwap/hig/contracts';
|
|
2
|
+
/**
|
|
3
|
+
* Native number display. Hermes on iOS ignores `signDisplay` (`exceptZero` drew `12.34%` where Android drew `+12.34%`), so every
|
|
4
|
+
* native figure composes its sign in HIG's own code instead of asking Intl for it: iOS and Android draw the same string, and it is
|
|
5
|
+
* the string an Intl that honours `signDisplay` draws. Display only.
|
|
6
|
+
*/
|
|
7
|
+
export function formatNumber(value, locale = 'en-US', options = {}) {
|
|
8
|
+
return formatSignedNumber(value, locale, options);
|
|
9
|
+
}
|
package/native/dist/pickers.d.ts
CHANGED
|
@@ -32,9 +32,17 @@ export interface PickerListProps {
|
|
|
32
32
|
searchInputProps?: PickerInputProps;
|
|
33
33
|
/** The list component the rows render through, such as a bottom sheet library's `FlatList`, so the list scrolls inside the host's sheet. Defaults to the `SwapHostContext` list, then React Native's `FlatList`. It receives the bounded `style` HIG sets, which the host's component may override. */
|
|
34
34
|
listComponent?: React.ComponentType<FlatListProps<SwapToken>>;
|
|
35
|
+
/** Host props for each token's row, such as `{testID: \`token-${token.id}\`}` in place of the built-in `swap-token-<id>`. HIG keeps the row's role, name, selected state and press. */
|
|
36
|
+
tokenRowProps?: (token: SwapToken) => PickerRowProps;
|
|
35
37
|
}
|
|
36
38
|
/** Host props for a picker's input: what a `TextInput` takes, except the value and its change handler. */
|
|
37
39
|
export type PickerInputProps = Omit<TextInputProps, 'value' | 'defaultValue' | 'onChangeText' | 'onChange'>;
|
|
40
|
+
/** Host props for one token row: its `testID` (replacing `swap-token-<id>`), `nativeID` and `accessibilityHint`. */
|
|
41
|
+
export interface PickerRowProps {
|
|
42
|
+
testID?: string;
|
|
43
|
+
nativeID?: string;
|
|
44
|
+
accessibilityHint?: string;
|
|
45
|
+
}
|
|
38
46
|
export interface FromPickerBlockProps extends PickerListProps {
|
|
39
47
|
/** The connected wallet. Omit for a list with no wallet row at all. */
|
|
40
48
|
wallet?: SwapWallet;
|
package/native/dist/pickers.js
CHANGED
|
@@ -18,7 +18,7 @@ function chainsOf(tokens) { const seen = new Map(); for (const token of tokens)
|
|
|
18
18
|
seen.set(token.chainId, { chainId: token.chainId, name: token.chain, icon: typeof token.chainIcon === 'string' ? token.chainIcon : undefined }); return [...seen.values()]; }
|
|
19
19
|
/** A row shows a known balance above zero, or a zero one when the host asks for it. */
|
|
20
20
|
const showBalance = (token, zero) => token.balance != null && Number.isFinite(token.balance) && (token.balance > 0 || (!!zero && token.balance === 0));
|
|
21
|
-
function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected = null, onSelect, loading, search = true, zeroBalances, searchLabel, searchRef, searchInputProps, listComponent, side, title }) {
|
|
21
|
+
function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected = null, onSelect, loading, search = true, zeroBalances, searchLabel, searchRef, searchInputProps, listComponent, tokenRowProps, side, title }) {
|
|
22
22
|
const { direction } = useHIG();
|
|
23
23
|
const colors = useColors();
|
|
24
24
|
const fills = useFills();
|
|
@@ -39,8 +39,8 @@ function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected =
|
|
|
39
39
|
// A visible label names the field through the Field context instead of the built-in name.
|
|
40
40
|
const field = _jsx(SearchInput, { ref: searchRef, accessibilityLabel: searchLabel ? undefined : t.swapSearchTokens, placeholder: t.swapSearchTokens, testID: `swap-search-${side}`, autoCapitalize: 'none', autoCorrect: false, autoComplete: 'off', spellCheck: false, ...searchInputProps, value: query, onChangeText: setQuery });
|
|
41
41
|
return _jsxs(_Fragment, { children: [search ? searchLabel ? _jsx(Field, { label: searchLabel, children: field }) : field : null, chainFilter && options.length > 1 ? _jsx(Filter, { label: t.swapChains, options: chainOptions, value: chain, onValueChange: pickChain }) : null, _jsx(List, { style: { height: Math.max(240, Math.round(window.height * 0.5)) }, data: rows, keyExtractor: token => token.id, keyboardShouldPersistTaps: 'handled', accessibilityLabel: title, testID: `swap-list-${side}`, initialNumToRender: 12, ListEmptyComponent: empty, renderItem: ({ item: token, index }) => {
|
|
42
|
-
const isSelected = selected?.id === token.id, balance = token.balance ?? 0, price = token.price ?? 0;
|
|
43
|
-
return _jsxs(View, { children: [hotCount > 0 && index === 0 ? section(t.swapHot) : null, hotCount > 0 && index === hotCount ? section(t.swapAllTokens) : null, _jsxs(Pressable, { accessibilityRole: 'button', accessibilityState: { selected: isSelected }, testID: `swap-token-${token.id}`, onPress: () => onSelect(token), style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', gap: 12, marginBottom: 4, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 9999, backgroundColor: pressed ? fills.well : 'transparent', opacity: isSelected ? 0.5 : 1 }), children: [_jsx(TokenIcon, { token: token }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: token.name }), _jsxs(Text, { style: { fontSize: 14, lineHeight: 21, color: colors.muted }, children: [token.detail ?? token.chain, isSelected ? ` · ${t.swapSelected}` : ''] })] }), showBalance(token, zeroBalances) ? _jsxs(View, { style: { alignItems: 'flex-end' }, children: [_jsx(AnimatedNumberReadout, { testID: `swap-token-balance-${token.id}`, value: balance, options: { maximumFractionDigits: 6 }, suffix: token.unitsSuffix, style: { fontWeight: '600', textAlign: 'right' } }), price > 0 ? _jsx(AnimatedNumberReadout, { testID: `swap-token-value-${token.id}`, value: balance * price, options: { style: 'currency', currency: 'USD' }, tone: 'muted', style: { fontSize: 14, lineHeight: 21, textAlign: 'right' } }) : null] }) : null] })] });
|
|
42
|
+
const isSelected = selected?.id === token.id, balance = token.balance ?? 0, price = token.price ?? 0, host = tokenRowProps?.(token);
|
|
43
|
+
return _jsxs(View, { children: [hotCount > 0 && index === 0 ? section(t.swapHot) : null, hotCount > 0 && index === hotCount ? section(t.swapAllTokens) : null, _jsxs(Pressable, { nativeID: host?.nativeID, accessibilityHint: host?.accessibilityHint, accessibilityRole: 'button', accessibilityState: { selected: isSelected }, testID: host?.testID ?? `swap-token-${token.id}`, onPress: () => onSelect(token), style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', gap: 12, marginBottom: 4, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 9999, backgroundColor: pressed ? fills.well : 'transparent', opacity: isSelected ? 0.5 : 1 }), children: [_jsx(TokenIcon, { token: token }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: token.name }), _jsxs(Text, { style: { fontSize: 14, lineHeight: 21, color: colors.muted }, children: [token.detail ?? token.chain, isSelected ? ` · ${t.swapSelected}` : ''] })] }), showBalance(token, zeroBalances) ? _jsxs(View, { style: { alignItems: 'flex-end' }, children: [_jsx(AnimatedNumberReadout, { testID: `swap-token-balance-${token.id}`, value: balance, options: { maximumFractionDigits: 6 }, suffix: token.unitsSuffix, style: { fontWeight: '600', textAlign: 'right' } }), price > 0 ? _jsx(AnimatedNumberReadout, { testID: `swap-token-value-${token.id}`, value: balance * price, options: { style: 'currency', currency: 'USD' }, tone: 'muted', style: { fontSize: 14, lineHeight: 21, textAlign: 'right' } }) : null] }) : null] })] });
|
|
44
44
|
} })] });
|
|
45
45
|
}
|
|
46
46
|
/**
|