@bloxwap/hig 0.6.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 +45 -2
- package/contracts/dist/index.js +145 -4
- package/contracts/dist/invariants.d.ts +17 -0
- package/contracts/dist/invariants.js +24 -0
- package/contracts/dist/messages.d.ts +62 -2
- package/contracts/dist/messages.js +22 -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 +62 -7
- package/native/dist/account-block.js +54 -11
- package/native/dist/animated-number-model.d.ts +47 -1
- package/native/dist/animated-number-model.js +248 -21
- package/native/dist/animated-number.d.ts +41 -1
- package/native/dist/animated-number.js +165 -17
- package/native/dist/announce.d.ts +2 -0
- package/native/dist/announce.js +10 -0
- package/native/dist/asset-balance-row.d.ts +19 -1
- package/native/dist/asset-balance-row.js +24 -8
- 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 +16 -2
- package/native/dist/bar-mark.js +23 -7
- package/native/dist/bar-pnl.js +7 -5
- package/native/dist/blocks.d.ts +13 -14
- package/native/dist/blocks.js +10 -6
- package/native/dist/brand.js +2 -1
- package/native/dist/button.d.ts +7 -2
- package/native/dist/button.js +16 -4
- 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 +8 -4
- package/native/dist/explainer-block.d.ts +91 -0
- package/native/dist/explainer-block.js +34 -0
- package/native/dist/field.d.ts +19 -5
- package/native/dist/field.js +56 -9
- package/native/dist/figure.d.ts +23 -0
- package/native/dist/figure.js +10 -0
- 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 +14 -1
- package/native/dist/language-block.js +11 -4
- package/native/dist/list-group.d.ts +44 -8
- package/native/dist/list-group.js +84 -13
- package/native/dist/manage-position-block.d.ts +35 -2
- package/native/dist/manage-position-block.js +41 -11
- package/native/dist/market-row.d.ts +46 -0
- package/native/dist/market-row.js +41 -0
- package/native/dist/navigation.js +5 -3
- package/native/dist/notifications-block.d.ts +30 -2
- package/native/dist/notifications-block.js +16 -8
- package/native/dist/number-format.d.ts +6 -0
- package/native/dist/number-format.js +9 -0
- package/native/dist/pickers.d.ts +32 -2
- package/native/dist/pickers.js +17 -9
- package/native/dist/position-block.d.ts +66 -10
- package/native/dist/position-block.js +45 -11
- 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 +38 -5
- package/native/dist/profile-block.js +31 -6
- package/native/dist/provider.d.ts +14 -5
- package/native/dist/provider.js +32 -6
- package/native/dist/qr-code.d.ts +33 -0
- package/native/dist/qr-code.js +29 -0
- package/native/dist/radio-group.d.ts +23 -5
- package/native/dist/radio-group.js +40 -12
- package/native/dist/recipes.d.ts +6 -0
- package/native/dist/recipes.js +6 -0
- package/native/dist/reward-block.d.ts +55 -13
- package/native/dist/reward-block.js +37 -14
- package/native/dist/screen-header.d.ts +59 -0
- package/native/dist/screen-header.js +37 -0
- package/native/dist/select.js +4 -2
- package/native/dist/selection.d.ts +3 -2
- package/native/dist/selection.js +1 -0
- package/native/dist/setting-header.d.ts +2 -8
- package/native/dist/setting-header.js +2 -11
- package/native/dist/setting-switch.d.ts +15 -2
- package/native/dist/setting-switch.js +11 -4
- package/native/dist/signals-block.d.ts +26 -2
- package/native/dist/signals-block.js +14 -4
- package/native/dist/slider.js +5 -1
- package/native/dist/sound-haptics-block.d.ts +29 -2
- package/native/dist/sound-haptics-block.js +19 -8
- package/native/dist/status.d.ts +47 -14
- package/native/dist/status.js +39 -22
- package/native/dist/sticky-header.d.ts +28 -0
- package/native/dist/sticky-header.js +29 -0
- package/native/dist/surface.d.ts +3 -1
- package/native/dist/surface.js +2 -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 +11 -4
- package/native/dist/swap-panel-block.js +67 -38
- package/native/dist/swap-parts.d.ts +5 -10
- package/native/dist/swap-parts.js +22 -24
- package/native/dist/swap-shared.d.ts +8 -2
- package/native/dist/swap-shared.js +10 -6
- package/native/dist/swap-views.js +6 -4
- package/native/dist/switch-row.d.ts +3 -2
- package/native/dist/switch-row.js +5 -3
- package/native/dist/switch.d.ts +4 -2
- package/native/dist/switch.js +3 -3
- package/native/dist/target-block.d.ts +40 -7
- package/native/dist/target-block.js +31 -11
- package/native/dist/toast.d.ts +47 -0
- package/native/dist/toast.js +386 -0
- package/native/dist/token-action-block.d.ts +26 -9
- package/native/dist/token-action-block.js +21 -8
- package/native/dist/trade-history-detail-block.d.ts +26 -1
- package/native/dist/trade-history-detail-block.js +17 -9
- package/native/dist/trade-history-list-block.d.ts +71 -5
- package/native/dist/trade-history-list-block.js +55 -17
- package/native/dist/wallet-address-core.d.ts +25 -0
- package/native/dist/wallet-address-core.js +34 -0
- package/native/dist/wallet-address.d.ts +6 -10
- package/native/dist/wallet-address.js +16 -20
- package/native-fonts/README.md +1 -1
- package/og-fonts/README.md +1 -1
- package/package.json +131 -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 +24 -0
- package/react/dist/animated-number-model.js +106 -3
- package/react/dist/animated-number.d.ts +49 -1
- package/react/dist/animated-number.js +146 -11
- package/react/dist/asset-balance-row.d.ts +19 -1
- package/react/dist/asset-balance-row.js +17 -3
- 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/bar-mark.d.ts +5 -2
- package/react/dist/bar-mark.js +5 -3
- package/react/dist/blocks/account-block.d.ts +57 -7
- package/react/dist/blocks/account-block.js +51 -11
- 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 +9 -1
- package/react/dist/blocks/language-block.js +8 -6
- package/react/dist/blocks/manage-position-block.d.ts +30 -2
- package/react/dist/blocks/manage-position-block.js +23 -4
- package/react/dist/blocks/market-row.d.ts +20 -9
- package/react/dist/blocks/market-row.js +17 -4
- package/react/dist/blocks/notifications-block.d.ts +27 -2
- package/react/dist/blocks/notifications-block.js +11 -2
- package/react/dist/blocks/pickers.d.ts +30 -1
- package/react/dist/blocks/pickers.js +32 -10
- package/react/dist/blocks/position-block.d.ts +34 -11
- package/react/dist/blocks/position-block.js +16 -5
- 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 +33 -6
- package/react/dist/blocks/profile-block.js +31 -6
- package/react/dist/blocks/reward-block.d.ts +65 -21
- package/react/dist/blocks/reward-block.js +24 -11
- package/react/dist/blocks/screen-header.d.ts +34 -2
- package/react/dist/blocks/screen-header.js +17 -6
- package/react/dist/blocks/setting-switch.d.ts +14 -1
- package/react/dist/blocks/setting-switch.js +11 -4
- package/react/dist/blocks/signals-block.d.ts +23 -2
- package/react/dist/blocks/signals-block.js +6 -5
- package/react/dist/blocks/sound-haptics-block.d.ts +27 -3
- package/react/dist/blocks/sound-haptics-block.js +11 -7
- package/react/dist/blocks/sticky-header.d.ts +19 -0
- package/react/dist/blocks/sticky-header.js +103 -0
- package/react/dist/blocks/swap/amount-card.js +2 -1
- package/react/dist/blocks/swap/settings.js +4 -3
- package/react/dist/blocks/swap/shared.d.ts +29 -23
- package/react/dist/blocks/swap/shared.js +36 -32
- package/react/dist/blocks/swap-panel-block.d.ts +12 -3
- package/react/dist/blocks/swap-panel-block.js +72 -37
- package/react/dist/blocks/target-block.d.ts +35 -7
- package/react/dist/blocks/target-block.js +26 -12
- package/react/dist/blocks/token-action-block.d.ts +21 -8
- package/react/dist/blocks/token-action-block.js +9 -6
- package/react/dist/blocks/trade-history-detail-block.d.ts +23 -1
- package/react/dist/blocks/trade-history-detail-block.js +5 -4
- package/react/dist/blocks/trade-history-list-block.d.ts +31 -5
- package/react/dist/blocks/trade-history-list-block.js +20 -10
- package/react/dist/blocks.d.ts +12 -8
- package/react/dist/blocks.js +6 -2
- package/react/dist/brand.js +2 -1
- package/react/dist/button.d.ts +9 -3
- package/react/dist/button.js +12 -5
- package/react/dist/confetti.d.ts +27 -0
- package/react/dist/confetti.js +240 -0
- package/react/dist/data.js +11 -4
- package/react/dist/field.d.ts +20 -5
- package/react/dist/field.js +30 -8
- package/react/dist/figure.d.ts +23 -0
- package/react/dist/figure.js +12 -0
- package/react/dist/gesture-sheet.d.ts +15 -1
- package/react/dist/gesture-sheet.js +53 -8
- package/react/dist/list-group.d.ts +41 -8
- package/react/dist/list-group.js +49 -13
- 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 +42 -5
- package/react/dist/provider.js +84 -10
- 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 +18 -4
- package/react/dist/selection.js +20 -10
- 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 +380 -150
- package/react/dist/surface.d.ts +5 -1
- package/react/dist/surface.js +1 -1
- package/react/dist/toast.d.ts +19 -12
- package/react/dist/toast.js +29 -7
- package/react/dist/wallet-address-core.d.ts +27 -0
- package/react/dist/wallet-address-core.js +29 -0
- package/react/dist/wallet-address.d.ts +6 -12
- package/react/dist/wallet-address.js +5 -16
- 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`. */
|
|
@@ -23,9 +24,21 @@ export interface LanguageBlockProps {
|
|
|
23
24
|
onSelect: (language: LanguageOption) => void;
|
|
24
25
|
/** Set false to leave out the search field, for a short list. Default `true`. */
|
|
25
26
|
search?: boolean;
|
|
27
|
+
/** Dims the rows and ignores presses, for example while a change is being applied. */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** A muted line under the header that explains the screen: Choose the language used throughout the app. */
|
|
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;
|
|
26
39
|
testID?: string;
|
|
27
40
|
}
|
|
28
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. */
|
|
29
42
|
export declare function filterLanguages(languages: readonly LanguageOption[], query: string): LanguageOption[];
|
|
30
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. */
|
|
31
|
-
export declare function LanguageBlock({ title, onBack, headerAction, languages, value, onSelect, search, 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, 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: { checked: selected }, accessibilityLabel: [language.name, language.description].filter(Boolean).join(', '), accessibilityLanguage: language.code, onPress: () => onSelect(language), style: ({ 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
|
}
|
|
@@ -1,26 +1,62 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { View, type PressableProps } from 'react-native';
|
|
3
|
+
/** A text action on the trailing edge of a `ListGroup` heading, such as “Cancel all”. */
|
|
4
|
+
export interface ListGroupAction {
|
|
5
|
+
/** Host text drawn as the action and naming it. */
|
|
6
|
+
label: string;
|
|
7
|
+
onSelect: () => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
2
10
|
export interface ListGroupProps {
|
|
3
|
-
/** Heading above the group, such as “Settings
|
|
4
|
-
title?:
|
|
11
|
+
/** Heading above the group, such as “Settings”: host text or an element such as a live count. Omit it for an untitled group. */
|
|
12
|
+
title?: React.ReactNode;
|
|
13
|
+
/** Host content after the title, such as a count or a figure; a string is drawn muted. */
|
|
14
|
+
titleAccessory?: React.ReactNode;
|
|
15
|
+
/** A text action on the trailing edge of the heading. */
|
|
16
|
+
action?: ListGroupAction;
|
|
17
|
+
/** Host content between the heading and the rows, such as a note or a field. A group with `intro` and no rows draws no row container. */
|
|
18
|
+
intro?: React.ReactNode;
|
|
5
19
|
/** `ListRow` elements. */
|
|
6
20
|
children?: React.ReactNode;
|
|
7
21
|
testID?: string;
|
|
8
22
|
}
|
|
9
23
|
/** A grouped list for menus and settings: an optional heading over rows that share one rounded container. */
|
|
10
|
-
export declare function ListGroup({ title, children, testID }: ListGroupProps): React.JSX.Element;
|
|
11
|
-
export interface ListRowProps {
|
|
24
|
+
export declare function ListGroup({ title, titleAccessory, action, intro, children, testID }: ListGroupProps): React.JSX.Element;
|
|
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'> {
|
|
12
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). 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
|
+
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;
|
|
31
|
+
/** Colours the label: `destructive` for an action that deletes or ends something, `muted` for one that is done or inactive. */
|
|
32
|
+
tone?: 'destructive' | 'muted';
|
|
13
33
|
/** Artwork before the label, such as an icon. Decorative: the label names the row. */
|
|
14
34
|
leading?: React.ReactNode;
|
|
15
|
-
/** Short text on the trailing edge, such as `Off`, `English` or a balance. A string is drawn muted and read with the label. */
|
|
35
|
+
/** Short text on the trailing edge, such as `Off`, `English` or a balance. A string or number is drawn muted, or in `valueTone`, and read with the label. */
|
|
16
36
|
value?: React.ReactNode;
|
|
37
|
+
/** What a `value` that is not text reads as, such as the formatted amount of a live figure. The element is then read as this text in its place: with the label on a pressable row, and on its own on a static row. */
|
|
38
|
+
valueLabel?: string;
|
|
39
|
+
/** Colours a string or number `value` instead of the muted default, keeping its layout and reading. */
|
|
40
|
+
valueTone?: 'positive' | 'warning' | 'negative' | 'muted';
|
|
17
41
|
/** Anything richer on the trailing edge: icons, a Badge, or a control such as a Switch. */
|
|
18
42
|
trailing?: React.ReactNode;
|
|
19
43
|
/** Makes the whole row a button, usually one that opens another view, and shows the disclosure chevron. */
|
|
20
44
|
onSelect?: () => void;
|
|
21
|
-
/** Dims the row and blocks `onSelect
|
|
45
|
+
/** Dims the row and blocks `onSelect` and the switch. */
|
|
22
46
|
disabled?: boolean;
|
|
47
|
+
/** A row in a list of choices, such as a picker that selects and closes: `true` draws a check on the trailing edge, and the row exposes `accessibilityState.selected`. With `selected` set, true or false, the row draws no chevron unless `disclosure` asks for one. */
|
|
48
|
+
selected?: boolean;
|
|
49
|
+
/** Something the row started is in progress: a spinner takes the disclosure's place, the row is read as busy and presses are ignored, without dimming it. A busy switch row ignores presses and is read as unavailable. */
|
|
50
|
+
busy?: boolean;
|
|
51
|
+
/** Busy text appended to the accessible name while `busy` (not on Android, which speaks its own); defaults to HIGProvider `messages.busy`. `''` omits it. */
|
|
52
|
+
busyLabel?: string;
|
|
53
|
+
/** The glyph a row with `onSelect` draws on its trailing edge: the `chevron` (default), `external` (an arrow, for something that opens outside the app) or `none`. */
|
|
54
|
+
disclosure?: 'chevron' | 'external' | 'none';
|
|
55
|
+
/** Makes the row a switch: the whole row is the target, named by `label`, with the track on its trailing edge; `onCheckedChange` receives the new state. Use without `onSelect`. */
|
|
56
|
+
checked?: boolean;
|
|
57
|
+
defaultChecked?: boolean;
|
|
58
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
23
59
|
testID?: string;
|
|
24
60
|
}
|
|
25
|
-
/** 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;
|
|
26
|
-
export declare
|
|
61
|
+
/** 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. */
|
|
62
|
+
export declare const ListRow: React.ForwardRefExoticComponent<ListRowProps & React.RefAttributes<React.ComponentRef<typeof View>>>;
|
|
@@ -1,27 +1,98 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
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';
|
|
4
|
+
import React, { forwardRef, useState } from 'react';
|
|
5
|
+
import { ActivityIndicator, Platform, Pressable, Text as NativeText, View } from 'react-native';
|
|
6
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
3
7
|
import { useColors, useFills, useHIG } from './provider.js';
|
|
4
8
|
import { Text } from './surface.js';
|
|
5
9
|
import { ChevronIcon } from './icons.js';
|
|
10
|
+
import { SwitchRow } from './switch-row.js';
|
|
11
|
+
import { plainText } from './text-content.js';
|
|
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));
|
|
16
|
+
const actionSlop = { top: 12, bottom: 12, left: 8, right: 8 };
|
|
6
17
|
/** A grouped list for menus and settings: an optional heading over rows that share one rounded container. */
|
|
7
|
-
export function ListGroup({ title, children, testID }) {
|
|
18
|
+
export function ListGroup({ title, titleAccessory, action, intro, children, testID }) {
|
|
8
19
|
const colors = useColors(), { direction } = useHIG();
|
|
9
|
-
|
|
20
|
+
const titled = shown(title), accessory = shown(titleAccessory);
|
|
21
|
+
const titleStyle = { color: colors.muted, fontSize: 14, lineHeight: 20, fontWeight: '500' };
|
|
22
|
+
const titleTestID = testID ? `${testID}-title` : undefined;
|
|
23
|
+
// A string title keeps its 0.6.0 anatomy; an element title is one header node. With an accessory, the title and the accessory are one header node instead.
|
|
24
|
+
const joined = titled && accessory;
|
|
25
|
+
const role = joined ? {} : { accessibilityRole: 'header' };
|
|
26
|
+
const name = !titled ? null : typeof title === 'string' || typeof title === 'number'
|
|
27
|
+
? _jsx(Text, { ...role, testID: titleTestID, style: accessory || action ? { flexShrink: 1, ...titleStyle } : { paddingHorizontal: 4, ...titleStyle }, children: title })
|
|
28
|
+
: _jsx(View, { ...(joined ? {} : { accessible: true, ...role }), testID: titleTestID, style: accessory || action ? { flexShrink: 1 } : { paddingHorizontal: 4 }, children: title });
|
|
29
|
+
const extra = accessory ? _jsx(View, { testID: testID ? `${testID}-title-accessory` : undefined, style: { flexShrink: 1 }, children: typeof titleAccessory === 'string' || typeof titleAccessory === 'number' ? _jsx(Text, { style: titleStyle, children: titleAccessory }) : titleAccessory }) : null;
|
|
30
|
+
// An element with no text of its own, such as a live figure, leaves the platform to read the node's children.
|
|
31
|
+
const titleText = joined ? plainText(title) : '', accessoryText = joined ? plainText(titleAccessory) : '';
|
|
32
|
+
const heading = joined ? _jsxs(View, { accessible: true, accessibilityRole: 'header', accessibilityLabel: titleText && accessoryText ? `${titleText}, ${accessoryText}` : undefined, testID: testID ? `${testID}-heading` : undefined, style: { flexDirection: 'row', alignItems: 'center', gap: 8, flexShrink: 1, minWidth: 0 }, children: [name, extra] }) : _jsxs(_Fragment, { children: [name, extra] });
|
|
33
|
+
// The action stays outside the header node, so it remains its own button.
|
|
34
|
+
const header = !accessory && !action ? name : _jsxs(View, { testID: testID ? `${testID}-header` : undefined, style: { direction, flexDirection: 'row', alignItems: 'center', gap: 8, paddingHorizontal: 4, minWidth: 0 }, children: [heading, action ? _jsx(Pressable, { testID: testID ? `${testID}-action` : undefined, accessibilityRole: 'button', accessibilityLabel: action.label, accessibilityState: { disabled: !!action.disabled }, disabled: action.disabled, hitSlop: actionSlop, onPress: action.onSelect, style: ({ pressed }) => ({ marginStart: 'auto', minWidth: 32, alignItems: 'center', paddingVertical: 4, paddingHorizontal: 4, opacity: action.disabled ? 0.5 : pressed ? 0.6 : 1 }), children: _jsx(Text, { accessible: false, style: { fontSize: 14, lineHeight: 20, fontWeight: '600', color: colors.text }, children: action.label }) }) : null] });
|
|
35
|
+
const empty = React.Children.count(children) === 0;
|
|
36
|
+
return _jsxs(View, { testID: testID, style: { direction, gap: 8, minWidth: 0 }, children: [header, shown(intro) ? _jsx(View, { testID: testID ? `${testID}-intro` : undefined, style: { paddingHorizontal: 4, minWidth: 0 }, children: intro }) : null, shown(intro) && empty ? null : _jsx(View, { testID: testID ? `${testID}-rows` : undefined, style: { gap: 2, borderRadius: 20, overflow: 'hidden' }, children: children })] });
|
|
10
37
|
}
|
|
11
38
|
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
39
|
+
/** The check of a selected row. It does not mirror in right-to-left layouts. */
|
|
40
|
+
function Check({ color, testID }) { return _jsx(SharedCheck, { size: 20, color: color, testID: testID }); }
|
|
41
|
+
/** An arrow pointing up and away, for a row that opens something outside the app; it mirrors in right-to-left layouts. */
|
|
42
|
+
function External({ color, rtl, testID }) { return _jsx(ArrowUpRight, { size: 20, color: color, testID: testID, style: { transform: rtl ? [{ scaleX: -1 }] : undefined } }); }
|
|
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. */
|
|
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) {
|
|
45
|
+
const colors = useColors(), fills = useFills(), { direction, messages } = useHIG();
|
|
46
|
+
const [internal, setInternal] = useState(!!defaultChecked);
|
|
47
|
+
const toggles = !onSelect && (checked !== undefined || defaultChecked !== undefined || onCheckedChange != null);
|
|
15
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 });
|
|
16
49
|
const text = typeof value === 'string' || typeof value === 'number';
|
|
17
|
-
const
|
|
50
|
+
const described = shown(description), about = described ? plainText(description) : '';
|
|
51
|
+
const reading = accessibilityLabel ?? [label, about || null, text ? String(value) : valueLabel ?? null].filter(Boolean).join(', ');
|
|
52
|
+
const busyText = busyLabel ?? messages.busy ?? en.busy;
|
|
53
|
+
const spoken = busy && busyText && Platform.OS !== 'android' ? `${reading} · ${busyText}` : reading;
|
|
18
54
|
// Everything aligns to the first line of the label, so a trailing switch stays at the top when the label wraps.
|
|
19
55
|
const first = { minHeight: 40, justifyContent: 'center' };
|
|
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.
|
|
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;
|
|
20
62
|
const lead = leading == null ? null : _jsx(View, { ...hidden, style: first, children: leading });
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
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;
|
|
70
|
+
const name = described
|
|
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 });
|
|
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 });
|
|
76
|
+
const chevron = _jsx(View, { testID: testID ? `${testID}-chevron` : undefined, style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) });
|
|
77
|
+
const glyphKind = disclosure ?? (selected !== undefined ? 'none' : 'chevron');
|
|
78
|
+
const glyph = busy && !toggles ? _jsx(ActivityIndicator, { testID: testID ? `${testID}-busy` : undefined, size: 'small', color: colors.muted, ...hidden })
|
|
79
|
+
: selected ? _jsx(Check, { color: colors.text, testID: testID ? `${testID}-check` : undefined })
|
|
80
|
+
: onSelect ? (glyphKind === 'chevron' ? chevron : glyphKind === 'external' ? _jsx(External, { color: colors.muted, rtl: direction === 'rtl', testID: testID ? `${testID}-external` : undefined }) : null) : null;
|
|
81
|
+
const end = glyph ? _jsx(View, { ...hidden, style: first, children: glyph }) : null;
|
|
82
|
+
if (toggles) {
|
|
83
|
+
const on = checked ?? internal;
|
|
84
|
+
const hint = [about || null, text ? String(value) : valueLabel ?? null].filter(Boolean).join(', ') || undefined;
|
|
85
|
+
// The row holds an uncontrolled state itself so the drawn track follows it; SwitchRow stays controlled and emits feedback once.
|
|
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)
|
|
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 }) });
|
|
88
|
+
}
|
|
89
|
+
const state = { ...(selected !== undefined ? { selected } : {}), ...(busy ? { busy: true } : {}) };
|
|
24
90
|
if (!onSelect)
|
|
25
|
-
return _jsxs(View, { testID: testID, style: row(false), children: [lead, name, amount, extra] });
|
|
26
|
-
return _jsxs(Pressable, { testID: testID, accessibilityRole: 'button', accessibilityLabel:
|
|
91
|
+
return _jsxs(View, { ...rest, ref: ref, testID: testID, ...(announced ? { accessible: true, accessibilityLabel: spoken } : {}), accessibilityState: Object.keys(state).length ? state : undefined, style: row(false), children: [lead, name, amount, extra, end] });
|
|
92
|
+
return _jsxs(Pressable, { ...rest, ref: ref, testID: testID, accessibilityRole: 'button', accessibilityLabel: spoken, accessibilityState: { disabled: !!disabled, ...state }, "aria-busy": busy || undefined, disabled: disabled, onPress: busy ? undefined : onSelect, style: ({ pressed }) => row(pressed && !busy), children: [lead, name, amount, extra, end] });
|
|
93
|
+
});
|
|
94
|
+
/** The decorative anatomy of a switch row: the label, value and trailing content, then the track. */
|
|
95
|
+
function SwitchRowContent({ first, lead, name, amount, extra, checked, testID }) {
|
|
96
|
+
const colors = useColors(), fills = useFills();
|
|
97
|
+
return _jsxs(View, { style: { flex: 1, flexDirection: 'row', alignItems: 'flex-start', gap: 12 }, children: [lead, name, amount, extra, _jsx(View, { style: first, children: _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 } }) }) })] });
|
|
27
98
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type ScrollViewProps } from 'react-native';
|
|
3
|
+
import { type Figure } from './figure.js';
|
|
2
4
|
import type { AssetArtwork } from './asset-balance-row.js';
|
|
3
5
|
export type { AssetArtwork } from './asset-balance-row.js';
|
|
4
6
|
/** Every trading word of the block. HIG's built-in strings hold no trading terms, so the host supplies them, translated. */
|
|
@@ -15,15 +17,36 @@ export interface ManagePositionBlockLabels {
|
|
|
15
17
|
long: string;
|
|
16
18
|
short: string;
|
|
17
19
|
}
|
|
20
|
+
/** A number the host supplies as a number so it updates place by place: `{value:66000,options:{style:'currency',currency:'USD'}}`. `null` reads as unknown. */
|
|
21
|
+
export type ManagePositionBlockFigure = Figure;
|
|
22
|
+
/** The position's artwork: an image URL, a host element, or a function that draws a host element and receives `failed`, to call when that element cannot draw (an SVG that did not load); the row then shows `iconFallback` or the initials. */
|
|
23
|
+
export type ManagePositionIcon = AssetArtwork | ((failed: () => void) => React.ReactNode);
|
|
18
24
|
export interface ManagePositionBlockAction {
|
|
19
25
|
id: string;
|
|
20
26
|
label: string;
|
|
21
27
|
onSelect: () => void;
|
|
22
28
|
disabled?: boolean;
|
|
29
|
+
/** Trailing value of the row, before the chevron: host text or a live figure, such as the price a resting trigger is set at. */
|
|
30
|
+
value?: string | ManagePositionBlockFigure;
|
|
31
|
+
/** Colours `value`. The default is the muted value colour. */
|
|
32
|
+
tone?: 'positive' | 'negative' | 'muted';
|
|
23
33
|
}
|
|
24
34
|
export interface ManagePositionBlockSummary {
|
|
25
35
|
name: string;
|
|
26
|
-
|
|
36
|
+
/** An image URL, a host element, or a function that draws one and reports its failure. An image or element that fails shows `iconFallback`, else the initials. */
|
|
37
|
+
icon?: ManagePositionIcon;
|
|
38
|
+
/** A host element drawn in place of an `icon` that failed to draw. Without it the row shows the initials. */
|
|
39
|
+
iconFallback?: React.ReactNode;
|
|
40
|
+
/** Short ticker for the initials when there is no artwork: BTC. Without it the first letters of the name are shown. */
|
|
41
|
+
symbol?: string;
|
|
42
|
+
/** Host text after the name, drawn as a small Badge, such as a venue. */
|
|
43
|
+
badge?: string;
|
|
44
|
+
/** One line under the row, such as that the profit and loss is stale or estimated. */
|
|
45
|
+
caption?: string;
|
|
46
|
+
/** Makes the whole row a button, for example one that opens the market. Needs `label`. */
|
|
47
|
+
onSelect?: () => void;
|
|
48
|
+
/** Accessible name of the row when it is a button, read before the figures, which stay in the label: View Bitcoin. The caption is its hint. */
|
|
49
|
+
label?: string;
|
|
27
50
|
/** 40 reads `40×`. */
|
|
28
51
|
leverage?: number;
|
|
29
52
|
/** Size in asset units. */
|
|
@@ -47,10 +70,20 @@ export interface ManagePositionBlockProps {
|
|
|
47
70
|
priceOptions?: Intl.NumberFormatOptions;
|
|
48
71
|
actions: readonly ManagePositionBlockAction[];
|
|
49
72
|
position?: ManagePositionBlockSummary;
|
|
73
|
+
/** Format of the position's profit and loss, merged over the default: signed US dollars with up to four decimals. */
|
|
74
|
+
pnlOptions?: Intl.NumberFormatOptions;
|
|
50
75
|
/** Shows Back on the leading edge of the header. */
|
|
51
76
|
onBack?: () => void;
|
|
52
77
|
/** A control on the trailing edge of the header, usually an IconButton. */
|
|
53
78
|
headerAction?: React.ReactNode;
|
|
79
|
+
/** Sets `nativeID` on the title, so a sheet around the pane can name itself with `accessibilityLabelledBy` (Android). */
|
|
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>;
|
|
54
87
|
testID?: string;
|
|
55
88
|
}
|
|
56
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. */
|
|
@@ -66,4 +99,4 @@ export declare function positionCorridor({ side, entry, mark, liquidation }: {
|
|
|
66
99
|
share: number | null;
|
|
67
100
|
};
|
|
68
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. */
|
|
69
|
-
export declare function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, onBack, headerAction, 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;
|