@bloxwap/hig 0.0.0-stage → 0.5.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/LICENSE +5 -0
- package/README.md +44 -2
- package/chart/README.md +23 -0
- package/chart/dist/index.d.ts +8 -0
- package/chart/dist/index.js +12 -0
- package/contracts/README.md +3 -0
- package/contracts/dist/announcements.d.ts +12 -0
- package/contracts/dist/announcements.js +8 -0
- package/contracts/dist/feedback.d.ts +40 -0
- package/contracts/dist/feedback.js +1 -0
- package/contracts/dist/index.d.ts +41 -0
- package/contracts/dist/index.js +52 -0
- package/contracts/dist/messages.d.ts +300 -0
- package/contracts/dist/messages.js +114 -0
- package/css.d.ts +2 -0
- package/feedback/README.md +7 -0
- package/feedback/assets/error.wav +0 -0
- package/feedback/assets/manifest.json +78 -0
- package/feedback/assets/success.wav +0 -0
- package/feedback/assets/tick.wav +0 -0
- package/feedback/assets/toggle.wav +0 -0
- package/feedback/dist/browser-haptic.d.ts +23 -0
- package/feedback/dist/browser-haptic.js +41 -0
- package/feedback/dist/contract.d.ts +40 -0
- package/feedback/dist/contract.js +59 -0
- package/feedback/dist/native.d.ts +28 -0
- package/feedback/dist/native.js +63 -0
- package/feedback/dist/preferences.d.ts +8 -0
- package/feedback/dist/preferences.js +24 -0
- package/feedback/dist/presets.d.ts +57 -0
- package/feedback/dist/presets.js +1 -0
- package/feedback/dist/react.d.ts +19 -0
- package/feedback/dist/react.js +23 -0
- package/feedback/dist/web-haptic.d.ts +6 -0
- package/feedback/dist/web-haptic.js +6 -0
- package/feedback/dist/web-sound.d.ts +5 -0
- package/feedback/dist/web-sound.js +32 -0
- package/feedback/dist/web.d.ts +3 -0
- package/feedback/dist/web.js +4 -0
- package/native/README.md +16 -0
- package/native/android/build.gradle +28 -0
- package/native/android/src/main/java/com/bloxwap/hig/HIGAdjustableView.java +173 -0
- package/native/android/src/main/java/com/bloxwap/hig/HIGAdjustableViewManager.java +23 -0
- package/native/android/src/main/java/com/bloxwap/hig/HIGPackage.java +24 -0
- package/native/dist/animated-number-model.d.ts +24 -0
- package/native/dist/animated-number-model.js +110 -0
- package/native/dist/animated-number.d.ts +9 -0
- package/native/dist/animated-number.js +97 -0
- package/native/dist/brand.d.ts +7 -0
- package/native/dist/brand.js +7 -0
- package/native/dist/button.d.ts +30 -0
- package/native/dist/button.js +36 -0
- package/native/dist/checkbox.d.ts +3 -0
- package/native/dist/checkbox.js +11 -0
- package/native/dist/data.d.ts +57 -0
- package/native/dist/data.js +47 -0
- package/native/dist/field.d.ts +16 -0
- package/native/dist/field.js +26 -0
- package/native/dist/gesture-sheet.d.ts +73 -0
- package/native/dist/gesture-sheet.js +153 -0
- package/native/dist/icons.d.ts +21 -0
- package/native/dist/icons.js +20 -0
- package/native/dist/navigation.d.ts +48 -0
- package/native/dist/navigation.js +58 -0
- package/native/dist/overlay.d.ts +36 -0
- package/native/dist/overlay.js +65 -0
- package/native/dist/pickers.d.ts +54 -0
- package/native/dist/pickers.js +60 -0
- package/native/dist/provider.d.ts +62 -0
- package/native/dist/provider.js +67 -0
- package/native/dist/radio-group.d.ts +21 -0
- package/native/dist/radio-group.js +91 -0
- package/native/dist/recipes.d.ts +45 -0
- package/native/dist/recipes.js +32 -0
- package/native/dist/roles.d.ts +6 -0
- package/native/dist/roles.js +4 -0
- package/native/dist/select.d.ts +3 -0
- package/native/dist/select.js +9 -0
- package/native/dist/selection-types.d.ts +22 -0
- package/native/dist/selection-types.js +1 -0
- package/native/dist/selection.d.ts +8 -0
- package/native/dist/selection.js +7 -0
- package/native/dist/slider.d.ts +11 -0
- package/native/dist/slider.js +42 -0
- package/native/dist/status.d.ts +86 -0
- package/native/dist/status.js +112 -0
- package/native/dist/surface.d.ts +19 -0
- package/native/dist/surface.js +42 -0
- package/native/dist/swap-panel.d.ts +125 -0
- package/native/dist/swap-panel.js +177 -0
- package/native/dist/swap-parts.d.ts +86 -0
- package/native/dist/swap-parts.js +66 -0
- package/native/dist/swap-shared.d.ts +65 -0
- package/native/dist/swap-shared.js +76 -0
- package/native/dist/swap-sheet.d.ts +14 -0
- package/native/dist/swap-sheet.js +26 -0
- package/native/dist/swap-views.d.ts +41 -0
- package/native/dist/swap-views.js +37 -0
- package/native/dist/switch-row.d.ts +8 -0
- package/native/dist/switch-row.js +18 -0
- package/native/dist/switch.d.ts +10 -0
- package/native/dist/switch.js +30 -0
- package/native/dist/text-content.d.ts +5 -0
- package/native/dist/text-content.js +6 -0
- package/native/dist/wallet-address.d.ts +37 -0
- package/native/dist/wallet-address.js +50 -0
- package/native-fonts/README.md +17 -0
- package/native-fonts/dist/index.d.ts +164 -0
- package/native-fonts/dist/index.js +164 -0
- package/native-fonts/fonts/BloxwapMono-Bold.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono-ExtraBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono-Medium.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-Black.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-Bold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-ExtraBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-Medium.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansKR-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansKR.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansSC-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansSC.ttf +0 -0
- package/native-fonts/fonts/OFL.txt +93 -0
- package/native-fonts/fonts/manifest.json +164 -0
- package/og-fonts/README.md +34 -0
- package/og-fonts/dist/index.d.ts +116 -0
- package/og-fonts/dist/index.js +102 -0
- package/og-fonts/dist/node.d.ts +11 -0
- package/og-fonts/dist/node.js +39 -0
- package/og-fonts/fonts/BloxwapMono-Medium.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans-Black.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans-Bold.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans-Medium.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans.ttf +0 -0
- package/og-fonts/fonts/OFL.txt +93 -0
- package/og-fonts/fonts/manifest.json +65 -0
- package/package.json +476 -4
- package/react/README.md +30 -0
- package/react/dist/animated-number-model.d.ts +20 -0
- package/react/dist/animated-number-model.js +92 -0
- package/react/dist/animated-number.d.ts +8 -0
- package/react/dist/animated-number.js +72 -0
- package/react/dist/base.css +9 -0
- package/react/dist/brand.d.ts +7 -0
- package/react/dist/brand.js +5 -0
- package/react/dist/button.d.ts +14 -0
- package/react/dist/button.js +20 -0
- package/react/dist/data.d.ts +78 -0
- package/react/dist/data.js +36 -0
- package/react/dist/dialog.d.ts +29 -0
- package/react/dist/dialog.js +21 -0
- package/react/dist/field.d.ts +16 -0
- package/react/dist/field.js +20 -0
- package/react/dist/gesture-sheet.d.ts +41 -0
- package/react/dist/gesture-sheet.js +128 -0
- package/react/dist/navigation.d.ts +48 -0
- package/react/dist/navigation.js +69 -0
- package/react/dist/notify.d.ts +14 -0
- package/react/dist/notify.js +6 -0
- package/react/dist/overlay.d.ts +17 -0
- package/react/dist/overlay.js +18 -0
- package/react/dist/provider.d.ts +25 -0
- package/react/dist/provider.js +50 -0
- package/react/dist/recipes/activity-list.d.ts +8 -0
- package/react/dist/recipes/activity-list.js +6 -0
- package/react/dist/recipes/balance-card.d.ts +6 -0
- package/react/dist/recipes/balance-card.js +5 -0
- package/react/dist/recipes/code-window.d.ts +4 -0
- package/react/dist/recipes/code-window.js +4 -0
- package/react/dist/recipes/install-command.d.ts +6 -0
- package/react/dist/recipes/install-command.js +15 -0
- package/react/dist/recipes/market-row.d.ts +25 -0
- package/react/dist/recipes/market-row.js +8 -0
- package/react/dist/recipes/marketing-hero.d.ts +7 -0
- package/react/dist/recipes/marketing-hero.js +5 -0
- package/react/dist/recipes/pickers.d.ts +57 -0
- package/react/dist/recipes/pickers.js +78 -0
- package/react/dist/recipes/swap/amount-card.d.ts +40 -0
- package/react/dist/recipes/swap/amount-card.js +7 -0
- package/react/dist/recipes/swap/picker.d.ts +26 -0
- package/react/dist/recipes/swap/picker.js +20 -0
- package/react/dist/recipes/swap/settings.d.ts +24 -0
- package/react/dist/recipes/swap/settings.js +25 -0
- package/react/dist/recipes/swap/shared.d.ts +98 -0
- package/react/dist/recipes/swap/shared.js +106 -0
- package/react/dist/recipes/swap-panel.d.ts +127 -0
- package/react/dist/recipes/swap-panel.js +170 -0
- package/react/dist/recipes/swap-sheet.d.ts +16 -0
- package/react/dist/recipes/swap-sheet.js +22 -0
- package/react/dist/recipes/trade-entry.d.ts +11 -0
- package/react/dist/recipes/trade-entry.js +12 -0
- package/react/dist/recipes.d.ts +10 -0
- package/react/dist/recipes.js +11 -0
- package/react/dist/select.d.ts +4 -0
- package/react/dist/select.js +174 -0
- package/react/dist/selection.d.ts +40 -0
- package/react/dist/selection.js +23 -0
- package/react/dist/slider.d.ts +11 -0
- package/react/dist/slider.js +10 -0
- package/react/dist/status.d.ts +63 -0
- package/react/dist/status.js +47 -0
- package/react/dist/styles.css +542 -0
- package/react/dist/surface.d.ts +291 -0
- package/react/dist/surface.js +9 -0
- package/react/dist/toast.d.ts +17 -0
- package/react/dist/toast.js +21 -0
- package/react/dist/wallet-address.d.ts +23 -0
- package/react/dist/wallet-address.js +24 -0
- package/tokens/README.md +17 -0
- package/tokens/assets/bloxwap-icon.svg +1 -0
- package/tokens/dist/brand.d.ts +19 -0
- package/tokens/dist/brand.js +24 -0
- package/tokens/dist/index.d.ts +437 -0
- package/tokens/dist/index.js +514 -0
- package/tokens/dist/manifest.json +200 -0
- package/tokens/dist/theme.d.ts +11 -0
- package/tokens/dist/theme.js +22 -0
- package/tokens/dist/tokens.css +120 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { forwardRef, useId, useRef } from 'react';
|
|
3
|
+
import { ActivityIndicator, Pressable, Linking, Platform, View } from 'react-native';
|
|
4
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
|
+
import { useColors, useFills, useHIG } from './provider.js';
|
|
6
|
+
import { Text } from './surface.js';
|
|
7
|
+
import { plainText } from './text-content.js';
|
|
8
|
+
/** Adjacent text children such as `{label}: {value}` form one Text run so the label wraps as words, not gapped fragments. */
|
|
9
|
+
function labelRuns(children) { const runs = []; for (const child of React.Children.toArray(children)) {
|
|
10
|
+
const text = typeof child === 'string' || typeof child === 'number' ? String(child) : null;
|
|
11
|
+
const last = runs.length - 1;
|
|
12
|
+
if (text !== null && typeof runs[last] === 'string')
|
|
13
|
+
runs[last] += text;
|
|
14
|
+
else
|
|
15
|
+
runs.push(text ?? child);
|
|
16
|
+
} return runs; }
|
|
17
|
+
/** A 44dp control keeps a 48dp touch target. */
|
|
18
|
+
const touchSlop = { top: 2, bottom: 2 };
|
|
19
|
+
/** Android appends its localized busy state; including the suffix there would speak it twice. */
|
|
20
|
+
export function busyAccessibilityLabel(text, busyText, os = Platform.OS) { return text ? (busyText && os !== 'android' ? `${text} · ${busyText}` : text) : undefined; }
|
|
21
|
+
export const Button = /* @__PURE__ */ forwardRef(function Button({ children, contentMode = 'default', intent = 'primary', disabled, busy, busyLabel, maxFontSizeMultiplier, script, fullWidth, suppressFeedback, onPress, style, ...props }, ref) { const env = useHIG(); const colors = useColors(); const fills = useFills(); const id = useId(); const sequence = useRef(0); const busyText = busyLabel ?? env.messages.busy ?? en.busy; const filled = intent === 'primary' || intent === 'destructive'; /* Unavailable is neutral: a well fill and muted text. Busy keeps the intent colour under its spinner. */ /* Unavailable is neutral: a well fill and muted text. Busy keeps the intent colour under its spinner. */ const inert = !!disabled && !busy; const label = plainText(children); const accessibleLabel = props.accessibilityLabel ?? (busy ? busyAccessibilityLabel(label, busyText) : undefined); const labelStyle = { color: inert ? (intent === 'ghost' ? colors.faint : colors.muted) : intent === 'destructive' ? colors.background : intent === 'primary' ? colors.onAction : intent === 'ghost' ? colors.muted : colors.text, fontSize: 16, fontWeight: '600', textAlign: 'center' }; return _jsx(Pressable, { ...props, ref: ref, disabled: disabled || busy, accessibilityRole: 'button', accessibilityLabel: accessibleLabel, accessibilityState: { ...props.accessibilityState, disabled: !!disabled || !!busy, busy: !!busy }, "aria-busy": !!busy, onPress: e => { if (disabled || busy)
|
|
22
|
+
return; e.stopPropagation(); onPress?.(e); if (!e.isDefaultPrevented() && !disabled && !busy && !suppressFeedback) {
|
|
23
|
+
try {
|
|
24
|
+
env.onAccepted?.(id);
|
|
25
|
+
env.feedback?.emit({ id: `${id}/${++sequence.current}`, source: id, intent: 'activate', origin: 'native' });
|
|
26
|
+
}
|
|
27
|
+
catch { /* Best effort only. */ }
|
|
28
|
+
} }, hitSlop: props.hitSlop ?? touchSlop, style: state => [{ minHeight: 44, paddingHorizontal: 20, paddingVertical: 10, borderRadius: 9999, alignItems: 'center', justifyContent: 'center', backgroundColor: inert ? (intent === 'ghost' ? 'transparent' : fills.well) : filled ? (intent === 'destructive' ? colors.negative : colors.action) : intent === 'ghost' && !state.pressed ? 'transparent' : colors.nested, opacity: busy ? 0.7 : state.pressed && !inert ? 0.85 : 1, alignSelf: fullWidth ? 'stretch' : 'flex-start' }, typeof style === 'function' ? style(state) : style], children: contentMode === 'custom' ? children : _jsxs(View, { style: { direction: env.direction, flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'center', gap: 8 }, children: [busy ? _jsx(ActivityIndicator, { size: 'small', color: labelStyle.color, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' }) : null, labelRuns(children).map((child, i) => typeof child === 'string' ? _jsx(Text, { script: script, maxFontSizeMultiplier: maxFontSizeMultiplier, style: labelStyle, children: child }, `label-${i}`) : child)] }) }); });
|
|
29
|
+
/** While busy, the spinner takes the icon's place. */
|
|
30
|
+
export function IconButton({ label, children, style, ...props }) { return _jsx(Button, { ...props, accessibilityLabel: label, style: state => [{ minWidth: 44, paddingHorizontal: 10 }, typeof style === 'function' ? style(state) : style], children: props.busy && props.contentMode !== 'custom' ? null : children }); }
|
|
31
|
+
export const Link = /* @__PURE__ */ forwardRef(function Link({ href, children, onError, onPress, contentMode = 'default', disabled, style, ...props }, ref) { const colors = useColors(); const web = Platform.OS === 'web', webHref = web && !disabled ? { href } : {}; return _jsx(Pressable, { ...props, ...webHref, ref: ref, accessibilityRole: 'link', disabled: disabled, accessibilityState: { ...props.accessibilityState, disabled: !!disabled }, "aria-busy": props.accessibilityState?.busy, onPress: event => { if (disabled)
|
|
32
|
+
return; if (onPress)
|
|
33
|
+
onPress(event);
|
|
34
|
+
else
|
|
35
|
+
void Linking.openURL(href).catch(onError ?? (() => { })); if (web)
|
|
36
|
+
event.preventDefault(); }, style: state => [{ minHeight: 48, minWidth: 48, justifyContent: 'center' }, typeof style === 'function' ? style(state) : style], children: contentMode === 'custom' ? children : _jsx(Text, { style: { color: colors.action, textDecorationLine: 'underline' }, children: children }) }); });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Pressable, View } from 'react-native';
|
|
3
|
+
import { nativeMetrics as tokens } from '@bloxwap/hig/tokens';
|
|
4
|
+
import { useColors, useControllable, useHIG } from './provider.js';
|
|
5
|
+
import { Text } from './surface.js';
|
|
6
|
+
export function Checkbox({ label, checked, defaultChecked = false, disabled, onCheckedChange }) {
|
|
7
|
+
const [current, set] = useControllable(checked, defaultChecked, onCheckedChange);
|
|
8
|
+
const colors = useColors(), env = useHIG();
|
|
9
|
+
return _jsxs(Pressable, { accessibilityRole: 'checkbox', "aria-checked": current, "aria-disabled": !!disabled, accessibilityLabel: label, accessibilityState: { checked: current, disabled: !!disabled }, disabled: disabled, onPress: () => { if (!disabled)
|
|
10
|
+
set(!current); }, style: { direction: env.direction, minHeight: 48, flexDirection: 'row', alignItems: 'center', gap: tokens.space.sm, opacity: disabled ? .5 : 1 }, children: [_jsx(View, { pointerEvents: 'none', accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', "aria-hidden": true, style: { width: 20, height: 20, flexShrink: 0, borderWidth: 1.5, borderColor: current ? colors.action : colors.muted, borderRadius: tokens.radius.sm, backgroundColor: current ? colors.action : colors.surface, alignItems: 'center', justifyContent: 'center' }, children: current && _jsx(View, { style: { width: 10, height: 6, borderLeftWidth: 2, borderBottomWidth: 2, borderColor: colors.onAction, transform: [{ translateY: -1 }, { rotate: '-45deg' }] } }) }), _jsx(Text, { style: { flexShrink: 1, minWidth: 0 }, children: label })] });
|
|
11
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type TextStyle } from 'react-native';
|
|
3
|
+
/** `up`/`down` are market direction (rising/long/gain, falling/short/loss) and follow `HIGProvider marketColors`; `positive`/`negative` stay success/error. */
|
|
4
|
+
export type NumberTone = 'text' | 'positive' | 'negative' | 'muted' | 'up' | 'down';
|
|
5
|
+
/** Typography only: semantic tone owns colour and numeric glyphs remain tabular. */
|
|
6
|
+
export type NumberReadoutStyle = Pick<TextStyle, 'fontFamily' | 'fontSize' | 'fontWeight' | 'lineHeight' | 'letterSpacing' | 'textAlign'>;
|
|
7
|
+
export interface NumberProps {
|
|
8
|
+
value: number | null | undefined;
|
|
9
|
+
options?: Intl.NumberFormatOptions; /** Host-owned display text for a finite value. Empty text falls back to locale formatting; never parse this text for submission. */
|
|
10
|
+
formattedValue?: string;
|
|
11
|
+
stale?: boolean;
|
|
12
|
+
label?: string; /** Explicit semantic meaning; sign alone never chooses the tone. */
|
|
13
|
+
tone?: NumberTone; /** Text typography, including an explicitly registered mono face. Does not style the animated wrapper. */
|
|
14
|
+
style?: StyleProp<NumberReadoutStyle>;
|
|
15
|
+
testID?: string; /** Font-scale cap for dense readouts, e.g. 2 for 200% at AX5. */
|
|
16
|
+
maxFontSizeMultiplier?: number; /** Display-only affixes, omitted for unknown values. */
|
|
17
|
+
prefix?: string;
|
|
18
|
+
suffix?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function NumberReadout({ value, options, formattedValue, stale, label, tone, style, testID, maxFontSizeMultiplier, prefix, suffix }: NumberProps): React.JSX.Element;
|
|
21
|
+
export declare function Usd(props: NumberProps): React.JSX.Element;
|
|
22
|
+
export declare function Percent(props: NumberProps): React.JSX.Element;
|
|
23
|
+
export declare function Metric({ label, value }: {
|
|
24
|
+
label: string;
|
|
25
|
+
value: React.ReactNode;
|
|
26
|
+
}): React.JSX.Element;
|
|
27
|
+
export declare const Stat: typeof Metric;
|
|
28
|
+
export declare function Row({ children }: React.PropsWithChildren): React.JSX.Element;
|
|
29
|
+
/** Native alternative to dense DOM tables: virtualized labeled rows. */
|
|
30
|
+
export interface ListProps<T> {
|
|
31
|
+
items: readonly T[];
|
|
32
|
+
keyFor: (item: T) => string;
|
|
33
|
+
render: (item: T) => React.ReactNode;
|
|
34
|
+
empty?: string;
|
|
35
|
+
label?: string;
|
|
36
|
+
loading?: boolean;
|
|
37
|
+
error?: string;
|
|
38
|
+
onRetry?: () => void;
|
|
39
|
+
onLoadMore?: () => void;
|
|
40
|
+
}
|
|
41
|
+
export declare function List<T>({ items, keyFor, render, empty, label, loading, error, onRetry, onLoadMore }: ListProps<T>): React.JSX.Element;
|
|
42
|
+
export type AddressKind = 'ethereum' | 'solana';
|
|
43
|
+
/** `0x…` is Ethereum-style (EVM); anything else lays out as Solana (base58). */
|
|
44
|
+
export declare function addressKind(address: string): AddressKind;
|
|
45
|
+
/** The address in fixed-width rows: 6 characters for Ethereum (42 characters make 7 rows), 4 for Solana (44 make 11). `anchor` marks the leading row and the trailing 4 characters, the ones people compare. */
|
|
46
|
+
export declare function addressRows(address: string, kind?: AddressKind): {
|
|
47
|
+
character: string;
|
|
48
|
+
anchor: boolean;
|
|
49
|
+
}[][];
|
|
50
|
+
export interface VerticalAddressProps {
|
|
51
|
+
address: string;
|
|
52
|
+
kind?: AddressKind; /** Row height in dp; the font size follows it. */
|
|
53
|
+
rowHeight?: number;
|
|
54
|
+
testID?: string;
|
|
55
|
+
}
|
|
56
|
+
/** A wallet address as a monospace column: the anchor characters in `text` at weight 600, the middle in `muted`. One selectable text element named by the whole address, always left to right. */
|
|
57
|
+
export declare function VerticalAddress({ address, kind, rowHeight, testID }: VerticalAddressProps): React.JSX.Element;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { FlatList, Platform, View, StyleSheet } from 'react-native';
|
|
4
|
+
import { formatNumberReadout } from './animated-number-model.js';
|
|
5
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
6
|
+
import { useColors, useHIG } from './provider.js';
|
|
7
|
+
import { Text, Surface, Separator } from './surface.js';
|
|
8
|
+
import { Button } from './button.js';
|
|
9
|
+
const numberTypographyKeys = new Set(['fontFamily', 'fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'textAlign']);
|
|
10
|
+
export function NumberReadout({ value, options, formattedValue, stale, label, tone = 'text', style, testID, maxFontSizeMultiplier, prefix, suffix }) {
|
|
11
|
+
const { locale, messages } = useHIG();
|
|
12
|
+
const colors = useColors();
|
|
13
|
+
const reading = formatNumberReadout(value, locale, options, formattedValue, prefix, suffix).text;
|
|
14
|
+
const staleSuffix = stale ? ` ${messages.stale ?? en.stale}` : '';
|
|
15
|
+
// Keep the same boundary for untyped hosts and registered/array styles: no raw colour, glyph or layout overrides.
|
|
16
|
+
const typography = Object.fromEntries(Object.entries(StyleSheet.flatten(style) ?? {}).filter(([key]) => numberTypographyKeys.has(key)));
|
|
17
|
+
const color = colors[tone === 'positive' || tone === 'negative' || tone === 'muted' || tone === 'up' || tone === 'down' ? tone : 'text'];
|
|
18
|
+
return _jsxs(Text, { accessibilityLabel: label ? `${label}: ${reading}${staleSuffix}` : undefined, testID: testID, maxFontSizeMultiplier: maxFontSizeMultiplier, style: [typography, { color, fontVariant: ['tabular-nums'] }], children: [reading, staleSuffix] });
|
|
19
|
+
}
|
|
20
|
+
export function Usd(props) { return _jsx(NumberReadout, { ...props, options: { style: 'currency', currency: 'USD', ...props.options } }); }
|
|
21
|
+
export function Percent(props) { return _jsx(NumberReadout, { ...props, value: props.value == null ? props.value : props.value / 100, options: { maximumFractionDigits: Math.max(3, props.options?.minimumFractionDigits ?? 0), ...props.options, style: 'percent' } }); }
|
|
22
|
+
export function Metric({ label, value }) { return _jsxs(Surface, { children: [_jsx(Text, { children: label }), value] }); }
|
|
23
|
+
export const Stat = Metric;
|
|
24
|
+
export function Row({ children }) { return _jsx(View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', flexWrap: 'wrap', gap: 12, paddingVertical: 12 }, children: children }); }
|
|
25
|
+
export function List({ items, keyFor, render, empty, label, loading = false, error, onRetry, onLoadMore }) {
|
|
26
|
+
const { messages } = useHIG();
|
|
27
|
+
return _jsx(FlatList, { data: items, accessibilityLabel: label, accessibilityState: { busy: loading }, keyExtractor: keyFor, renderItem: ({ item }) => _jsx(View, { children: render(item) }), ItemSeparatorComponent: Separator, ListEmptyComponent: !loading && !error ? _jsx(Text, { children: empty ?? messages.noItems ?? en.noItems }) : null, ListFooterComponent: _jsxs(View, { style: { gap: 12, paddingTop: loading || error || onLoadMore ? 12 : 0 }, children: [loading && _jsx(Text, { accessibilityLiveRegion: 'polite', children: messages.loadingItems ?? en.loadingItems }), error && _jsxs(View, { style: { gap: 12 }, children: [_jsx(Text, { accessibilityRole: 'alert', children: error }), onRetry && _jsx(Button, { disabled: loading, onPress: onRetry, children: messages.retry ?? en.retry })] }), onLoadMore && _jsx(Button, { disabled: loading, onPress: onLoadMore, children: messages.loadMore ?? en.loadMore })] }) });
|
|
28
|
+
}
|
|
29
|
+
/** `0x…` is Ethereum-style (EVM); anything else lays out as Solana (base58). */
|
|
30
|
+
export function addressKind(address) { return address.startsWith('0x') ? 'ethereum' : 'solana'; }
|
|
31
|
+
/** The address in fixed-width rows: 6 characters for Ethereum (42 characters make 7 rows), 4 for Solana (44 make 11). `anchor` marks the leading row and the trailing 4 characters, the ones people compare. */
|
|
32
|
+
export function addressRows(address, kind = addressKind(address)) {
|
|
33
|
+
const size = kind === 'ethereum' ? 6 : 4, tail = address.length - 4, rows = [];
|
|
34
|
+
for (let index = 0; index < address.length; index += size)
|
|
35
|
+
rows.push(Array.from(address.slice(index, index + size)).map((character, offset) => ({ character, anchor: index + offset < size || index + offset >= tail })));
|
|
36
|
+
return rows;
|
|
37
|
+
}
|
|
38
|
+
/** A wallet address as a monospace column: the anchor characters in `text` at weight 600, the middle in `muted`. One selectable text element named by the whole address, always left to right. */
|
|
39
|
+
export function VerticalAddress({ address, kind, rowHeight = 22, testID }) {
|
|
40
|
+
const env = useHIG();
|
|
41
|
+
const colors = useColors();
|
|
42
|
+
const mono = env.monoFontFamily ?? Platform.select({ ios: 'Menlo', default: 'monospace' });
|
|
43
|
+
const rows = addressRows(address, kind);
|
|
44
|
+
// HIG Text sets its own body size, so each character carries the row's type size instead of inheriting it.
|
|
45
|
+
const type = { fontFamily: mono, fontSize: Math.round(rowHeight / 1.1 * 10) / 10, lineHeight: rowHeight, letterSpacing: 1 };
|
|
46
|
+
return _jsx(Text, { selectable: true, accessibilityLabel: address, testID: testID, maxFontSizeMultiplier: 1.2, style: { ...type, fontVariant: ['tabular-nums'], writingDirection: 'ltr', textAlign: 'left' }, children: rows.map((row, index) => _jsxs(React.Fragment, { children: [index > 0 ? '\n' : null, row.map((cell, offset) => _jsx(Text, { maxFontSizeMultiplier: 1.2, style: { ...type, color: cell.anchor ? colors.text : colors.muted, fontWeight: cell.anchor ? '600' : '500' }, children: cell.character }, offset))] }, index)) });
|
|
47
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextInput, type TextInputProps } from 'react-native';
|
|
3
|
+
import { Text } from './surface.js';
|
|
4
|
+
export declare function Field({ label, description, error, required, disabled, children }: React.PropsWithChildren<{
|
|
5
|
+
label: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
error?: string;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}>): React.JSX.Element;
|
|
11
|
+
export declare const Label: typeof Text;
|
|
12
|
+
/** No resting stroke: the fill separates the field (one step lighter inside a Surface, Dialog or sheet). The ring appears only for focus and for an invalid value. */
|
|
13
|
+
export declare const Input: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<React.ComponentRef<typeof TextInput>>>;
|
|
14
|
+
export declare const TextArea: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<React.ComponentRef<typeof TextInput>>>;
|
|
15
|
+
export declare const AmountInput: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<React.ComponentRef<typeof TextInput>>>;
|
|
16
|
+
export declare const SearchInput: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<React.ComponentRef<typeof TextInput>>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, forwardRef, useId, useState } from 'react';
|
|
3
|
+
import { Platform, TextInput, View } from 'react-native';
|
|
4
|
+
import { SearchIcon } from './icons.js';
|
|
5
|
+
import { Text } from './surface.js';
|
|
6
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
7
|
+
import { useColors, useFills, useHIG } from './provider.js';
|
|
8
|
+
const Context = createContext({ label: '' });
|
|
9
|
+
export function Field({ label, description, error, required, disabled, children }) { const id = useId(); const { messages } = useHIG(); const colors = useColors(); const marked = required ? `${label} ${messages.required ?? en.required}` : label; return _jsx(Context.Provider, { value: { label: marked, hint: [description, error].filter(Boolean).join('. '), disabled, invalid: !!error }, children: _jsxs(View, { style: { gap: 8 }, children: [_jsx(Text, { nativeID: id, children: marked }), children, description && _jsx(Text, { style: { color: colors.muted }, children: description }), error && _jsx(Text, { accessibilityLiveRegion: 'polite', style: { color: colors.negative }, children: error })] }) }); }
|
|
10
|
+
export const Label = Text;
|
|
11
|
+
/** No resting stroke: the fill separates the field (one step lighter inside a Surface, Dialog or sheet). The ring appears only for focus and for an invalid value. */
|
|
12
|
+
export const Input = forwardRef(function Input({ style, onFocus, onBlur, ...props }, ref) { const field = useContext(Context); const colors = useColors(); const fills = useFills(); const env = useHIG(); const [focused, setFocused] = useState(false); return _jsx(TextInput, { ...props, ref: ref, accessibilityLabel: props.accessibilityLabel ?? field.label, accessibilityHint: props.accessibilityHint ?? field.hint, accessibilityState: { ...props.accessibilityState, disabled: !!field.disabled || !!props.accessibilityState?.disabled }, editable: field.disabled ? false : props.editable, onChangeText: field.disabled ? undefined : props.onChangeText, onChange: field.disabled ? undefined : props.onChange, onFocus: event => { setFocused(true); onFocus?.(event); }, onBlur: event => { setFocused(false); onBlur?.(event); }, placeholderTextColor: props.placeholderTextColor ?? colors.muted, style: [{ color: colors.text, backgroundColor: fills.well, minHeight: 48, borderWidth: 1.5, borderColor: field.invalid ? colors.negative : focused ? colors.faint : 'transparent', borderRadius: props.multiline ? 14 : 9999, paddingVertical: 12, paddingHorizontal: 20, fontSize: 16, fontFamily: env.fontFamilies?.[400] ?? env.fontFamily, opacity: field.disabled ? 0.5 : 1 }, style] }); });
|
|
13
|
+
export const TextArea = forwardRef(function TextArea(props, ref) { return _jsx(Input, { ...props, ref: ref, multiline: true, textAlignVertical: 'top' }); });
|
|
14
|
+
export const AmountInput = forwardRef(function AmountInput(props, ref) { return _jsx(Input, { ...props, ref: ref, keyboardType: props.keyboardType ?? 'decimal-pad' }); });
|
|
15
|
+
/** The magnifying glass sits inset on the leading edge and the text starts past it. */
|
|
16
|
+
/** A search box is as tall as a button, 44dp, not a 48dp form field. */
|
|
17
|
+
const searchSize = { minHeight: 44, paddingVertical: 10 };
|
|
18
|
+
export const SearchInput = forwardRef(function SearchInput({ style, ...props }, ref) {
|
|
19
|
+
const colors = useColors();
|
|
20
|
+
const { direction } = useHIG();
|
|
21
|
+
// RN Web resolves `start` through its own locale context rather than this View's direction.
|
|
22
|
+
const rtl = direction === 'rtl', web = Platform.OS === 'web';
|
|
23
|
+
const edge = web ? (rtl ? { right: 18 } : { left: 18 }) : { start: 18 };
|
|
24
|
+
const inset = web ? (rtl ? { paddingRight: 46 } : { paddingLeft: 46 }) : { paddingStart: 46 };
|
|
25
|
+
return _jsxs(View, { style: { direction, justifyContent: 'center' }, children: [_jsx(Input, { ...props, ref: ref, returnKeyType: props.returnKeyType ?? 'search', style: [searchSize, inset, style] }), _jsx(View, { pointerEvents: 'none', style: { position: 'absolute', ...edge }, children: _jsx(SearchIcon, { color: colors.muted }) })] });
|
|
26
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text as RNText, TextInput, View } from 'react-native';
|
|
3
|
+
import BottomSheet, { BottomSheetModal, type BottomSheetModalProps } from '@gorhom/bottom-sheet';
|
|
4
|
+
interface GestureSheetCommonProps {
|
|
5
|
+
open: boolean;
|
|
6
|
+
onOpenChange: (open: boolean) => void;
|
|
7
|
+
title: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
/** Default anatomy scrolls the title, description, content and Close action. Custom content owns layout, scrolling and dismissal actions. */
|
|
11
|
+
contentMode?: 'default' | 'custom';
|
|
12
|
+
/** In custom mode, attach to the caller-rendered accessible title. Without it, a visually hidden title receives open focus. */
|
|
13
|
+
titleRef?: React.RefObject<React.ComponentRef<typeof View> | React.ComponentRef<typeof RNText> | React.ComponentRef<typeof TextInput> | null>;
|
|
14
|
+
/** Content-heavy hosts may disable content panning while retaining their own scrollable gestures. */
|
|
15
|
+
enableContentPanningGesture?: BottomSheetModalProps['enableContentPanningGesture'];
|
|
16
|
+
/** Host keyboard policies; defaults retain HIG interactive/restore/adjustResize behavior. */
|
|
17
|
+
keyboardBehavior?: BottomSheetModalProps['keyboardBehavior'];
|
|
18
|
+
keyboardBlurBehavior?: BottomSheetModalProps['keyboardBlurBehavior'];
|
|
19
|
+
android_keyboardInputMode?: BottomSheetModalProps['android_keyboardInputMode'];
|
|
20
|
+
dismissible?: boolean;
|
|
21
|
+
returnFocusRef?: React.RefObject<React.ComponentRef<typeof View> | React.ComponentRef<typeof RNText> | React.ComponentRef<typeof TextInput> | null>;
|
|
22
|
+
/** Close button text and accessible name; defaults to HIGProvider `messages.close`. */
|
|
23
|
+
closeLabel?: string;
|
|
24
|
+
/** Called once after an accepted dismissal settles. Rejected or interrupted closes do not clear host card state. */
|
|
25
|
+
onDismiss?: () => void;
|
|
26
|
+
/** Observe backend detent changes after HIG updates its focus and controlled close state. */
|
|
27
|
+
onChange?: BottomSheetModalProps['onChange'];
|
|
28
|
+
/** Return true to consume Android Back, or false to defer to another host BackHandler. Omit for default sheet dismissal. */
|
|
29
|
+
onHardwareBackPress?: () => boolean;
|
|
30
|
+
/** Host geometry overrides; defaults to the real safe-area insets. Zero supports flush card stacks. */
|
|
31
|
+
topInset?: number;
|
|
32
|
+
bottomInset?: number;
|
|
33
|
+
/** Host-drawn handle and background slots. Use useColors() for host surfaces. */
|
|
34
|
+
handleComponent?: BottomSheetModalProps['handleComponent'];
|
|
35
|
+
handleStyle?: BottomSheetModalProps['handleStyle'];
|
|
36
|
+
handleIndicatorStyle?: BottomSheetModalProps['handleIndicatorStyle'];
|
|
37
|
+
backgroundComponent?: BottomSheetModalProps['backgroundComponent'];
|
|
38
|
+
backgroundStyle?: BottomSheetModalProps['backgroundStyle'];
|
|
39
|
+
/** Screen-level inline hosts may retain their existing sibling overlay order. */
|
|
40
|
+
containerStyle?: BottomSheetModalProps['containerStyle'];
|
|
41
|
+
/** Optional host animation and backdrop policies; HIG reduced-motion mapping remains applied. */
|
|
42
|
+
animateOnMount?: BottomSheetModalProps['animateOnMount'];
|
|
43
|
+
animationConfigs?: BottomSheetModalProps['animationConfigs'];
|
|
44
|
+
backdropComponent?: BottomSheetModalProps['backdropComponent'];
|
|
45
|
+
}
|
|
46
|
+
export type GestureSheetProps = GestureSheetCommonProps & (
|
|
47
|
+
/** Modal is the default. Inline retains the screen-level backend and its child state while closed. */
|
|
48
|
+
{
|
|
49
|
+
presentation?: 'modal';
|
|
50
|
+
modalRef?: React.Ref<BottomSheetModal>;
|
|
51
|
+
sheetRef?: never;
|
|
52
|
+
} | {
|
|
53
|
+
presentation: 'inline';
|
|
54
|
+
sheetRef?: React.Ref<BottomSheet>;
|
|
55
|
+
modalRef?: never;
|
|
56
|
+
}) & (
|
|
57
|
+
/** Fixed sizing keeps sorted increasing detents. Changes retain the current index or clamp a removed detent. */
|
|
58
|
+
{
|
|
59
|
+
enableDynamicSizing?: false;
|
|
60
|
+
snapPoints: readonly (number | `${number}%`)[];
|
|
61
|
+
initialIndex?: number;
|
|
62
|
+
maxDynamicContentSize?: never;
|
|
63
|
+
}
|
|
64
|
+
/** Content sizing uses one backend-measured detent and an optional finite positive point ceiling (default: container height), without fixed snap points or an initial detent index. */
|
|
65
|
+
| {
|
|
66
|
+
enableDynamicSizing: true;
|
|
67
|
+
snapPoints?: never;
|
|
68
|
+
initialIndex?: never;
|
|
69
|
+
maxDynamicContentSize?: BottomSheetModalProps['maxDynamicContentSize'];
|
|
70
|
+
});
|
|
71
|
+
/** Optional backend: host supplies GestureHandlerRootView, SafeAreaProvider and BottomSheetModalProvider. */
|
|
72
|
+
export declare function GestureSheet({ open, onOpenChange, title, description, children, contentMode, titleRef, presentation, sheetRef, snapPoints, enableDynamicSizing, maxDynamicContentSize, enableContentPanningGesture, keyboardBehavior, keyboardBlurBehavior, android_keyboardInputMode, initialIndex, dismissible, returnFocusRef, closeLabel, onDismiss, onChange, onHardwareBackPress, topInset, bottomInset, modalRef, handleComponent, handleStyle, handleIndicatorStyle, backgroundComponent, backgroundStyle, containerStyle, animateOnMount, animationConfigs, backdropComponent }: GestureSheetProps): React.JSX.Element;
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useCallback, useImperativeHandle } from 'react';
|
|
3
|
+
import { AccessibilityInfo, BackHandler, findNodeHandle, Platform, View } from 'react-native';
|
|
4
|
+
import BottomSheet, { BottomSheetModal, BottomSheetScrollView, BottomSheetBackdrop, BottomSheetView } from '@gorhom/bottom-sheet';
|
|
5
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
6
|
+
import { ReduceMotion } from 'react-native-reanimated';
|
|
7
|
+
import { nativeMetrics as tokens } from '@bloxwap/hig/tokens';
|
|
8
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
9
|
+
import { Raised, useColors, useHIG } from './provider.js';
|
|
10
|
+
import { Heading, Text, Stack } from './surface.js';
|
|
11
|
+
import { Button } from './button.js';
|
|
12
|
+
/** 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
|
+
if (enableDynamicSizing && snapPoints !== undefined)
|
|
15
|
+
throw new Error('Content-sized GestureSheet does not accept fixed snapPoints.');
|
|
16
|
+
const fixedSnapPoints = snapPoints ?? [];
|
|
17
|
+
if (!enableDynamicSizing && fixedSnapPoints.length === 0)
|
|
18
|
+
throw new Error('GestureSheet requires at least one snap point.');
|
|
19
|
+
if (maxDynamicContentSize !== undefined && (!Number.isFinite(maxDynamicContentSize) || maxDynamicContentSize <= 0))
|
|
20
|
+
throw new Error('GestureSheet maxDynamicContentSize must be finite and greater than zero.');
|
|
21
|
+
const detentCount = enableDynamicSizing ? 1 : fixedSnapPoints.length;
|
|
22
|
+
const sheet = useRef(null), inline = useRef(null), heading = useRef(null), requested = useRef(false), focused = useRef(false), frame = useRef(null), requestFrame = useRef(null);
|
|
23
|
+
useImperativeHandle(modalRef, () => sheet.current);
|
|
24
|
+
useImperativeHandle(sheetRef, () => inline.current);
|
|
25
|
+
const dismissed = useRef(true);
|
|
26
|
+
const startingIndex = Math.max(0, Math.min(initialIndex, detentCount - 1));
|
|
27
|
+
const activeIndex = useRef(startingIndex), detentFrame = useRef(null), pendingSnap = useRef(false);
|
|
28
|
+
const detentKey = JSON.stringify(fixedSnapPoints);
|
|
29
|
+
const latest = useRef({ open, onOpenChange, returnFocusRef, onDismiss, onHardwareBackPress });
|
|
30
|
+
latest.current = { open, onOpenChange, returnFocusRef, onDismiss, onHardwareBackPress };
|
|
31
|
+
const env = useHIG(), colors = useColors(), insets = useSafeAreaInsets();
|
|
32
|
+
const focus = useCallback((node) => { if (!node)
|
|
33
|
+
return; try {
|
|
34
|
+
const handle = findNodeHandle(node);
|
|
35
|
+
if (handle != null) {
|
|
36
|
+
AccessibilityInfo.setAccessibilityFocus(handle);
|
|
37
|
+
if (Platform.OS === 'android')
|
|
38
|
+
AccessibilityInfo.sendAccessibilityEvent(node, 'viewHoverEnter');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch { /* Detached focus targets cannot prevent dismissal. */ } }, []);
|
|
42
|
+
const requestClose = useCallback(() => {
|
|
43
|
+
if (requested.current || !latest.current.open)
|
|
44
|
+
return;
|
|
45
|
+
requested.current = true;
|
|
46
|
+
requestFrame.current = requestAnimationFrame(() => { requestFrame.current = null; if (latest.current.open)
|
|
47
|
+
requested.current = false; });
|
|
48
|
+
latest.current.onOpenChange(false);
|
|
49
|
+
}, []);
|
|
50
|
+
// Gorhom 5 marks a never-presented modal DISMISSING on dismiss() and then skips its portal render, so the sheet
|
|
51
|
+
// never appeared on the iOS Simulator or Android emulator. Only dismiss what this component presented.
|
|
52
|
+
const presented = useRef(false);
|
|
53
|
+
useEffect(() => { requested.current = false; focused.current = false; pendingSnap.current = false; if (requestFrame.current !== null) {
|
|
54
|
+
cancelAnimationFrame(requestFrame.current);
|
|
55
|
+
requestFrame.current = null;
|
|
56
|
+
} if (open) {
|
|
57
|
+
dismissed.current = false;
|
|
58
|
+
activeIndex.current = startingIndex;
|
|
59
|
+
presented.current = true;
|
|
60
|
+
if (presentation === 'inline')
|
|
61
|
+
inline.current?.snapToIndex(startingIndex);
|
|
62
|
+
else
|
|
63
|
+
sheet.current?.present();
|
|
64
|
+
}
|
|
65
|
+
else if (presented.current) {
|
|
66
|
+
presented.current = false;
|
|
67
|
+
if (presentation === 'inline')
|
|
68
|
+
inline.current?.close();
|
|
69
|
+
else
|
|
70
|
+
sheet.current?.dismiss();
|
|
71
|
+
} }, [open, presentation]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!open)
|
|
74
|
+
return;
|
|
75
|
+
if (enableDynamicSizing) {
|
|
76
|
+
activeIndex.current = 0;
|
|
77
|
+
pendingSnap.current = false;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Gorhom reacts to changed detent positions itself. Removing the active detent also needs a valid index;
|
|
81
|
+
// wait until the new geometry has reached the backend before requesting it.
|
|
82
|
+
if (activeIndex.current >= fixedSnapPoints.length || pendingSnap.current) {
|
|
83
|
+
activeIndex.current = Math.min(activeIndex.current, fixedSnapPoints.length - 1);
|
|
84
|
+
pendingSnap.current = true;
|
|
85
|
+
const index = activeIndex.current;
|
|
86
|
+
detentFrame.current = requestAnimationFrame(() => { detentFrame.current = null; pendingSnap.current = false; if (latest.current.open) {
|
|
87
|
+
activeIndex.current = index;
|
|
88
|
+
(presentation === 'inline' ? inline.current : sheet.current)?.snapToIndex(index);
|
|
89
|
+
} });
|
|
90
|
+
}
|
|
91
|
+
return () => { if (detentFrame.current !== null) {
|
|
92
|
+
cancelAnimationFrame(detentFrame.current);
|
|
93
|
+
detentFrame.current = null;
|
|
94
|
+
} };
|
|
95
|
+
}, [open, detentKey, enableDynamicSizing, presentation]);
|
|
96
|
+
useEffect(() => { if (!open)
|
|
97
|
+
return; const subscription = BackHandler.addEventListener('hardwareBackPress', () => { if (latest.current.onHardwareBackPress)
|
|
98
|
+
return latest.current.onHardwareBackPress(); if (dismissible)
|
|
99
|
+
requestClose(); return true; }); return () => subscription.remove(); }, [open, dismissible, requestClose]);
|
|
100
|
+
useEffect(() => () => { if (frame.current !== null)
|
|
101
|
+
cancelAnimationFrame(frame.current); if (requestFrame.current !== null)
|
|
102
|
+
cancelAnimationFrame(requestFrame.current); if (detentFrame.current !== null)
|
|
103
|
+
cancelAnimationFrame(detentFrame.current); }, []);
|
|
104
|
+
const backdrop = useCallback((props) => _jsx(BottomSheetBackdrop, { ...props, appearsOnIndex: 0, disappearsOnIndex: -1, pressBehavior: dismissible ? 'close' : 'none' }), [dismissible]);
|
|
105
|
+
// BottomSheetView reports intrinsic layout to Gorhom's dynamic sizing. Fixed custom content
|
|
106
|
+
// keeps a plain View so it does not replace the caller's nested scrollable registration.
|
|
107
|
+
const CustomContent = enableDynamicSizing ? BottomSheetView : View;
|
|
108
|
+
const handleChange = useCallback((index, position, type) => { if (index >= 0) {
|
|
109
|
+
activeIndex.current = index;
|
|
110
|
+
if (latest.current.open && !focused.current) {
|
|
111
|
+
focused.current = true;
|
|
112
|
+
focus(contentMode === 'custom' ? (titleRef?.current ?? heading.current) : heading.current);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else
|
|
116
|
+
requestClose(); onChange?.(index, position, type); }, [contentMode, titleRef, focus, requestClose, onChange]);
|
|
117
|
+
const handleSettledClose = useCallback(() => {
|
|
118
|
+
// An inline sheet initially mounts closed to prepare its children. That is not a dismissal.
|
|
119
|
+
if (dismissed.current && !latest.current.open)
|
|
120
|
+
return;
|
|
121
|
+
requestClose();
|
|
122
|
+
if (requestFrame.current !== null) {
|
|
123
|
+
cancelAnimationFrame(requestFrame.current);
|
|
124
|
+
requestFrame.current = null;
|
|
125
|
+
}
|
|
126
|
+
if (frame.current !== null)
|
|
127
|
+
cancelAnimationFrame(frame.current);
|
|
128
|
+
frame.current = requestAnimationFrame(() => { frame.current = null; if (latest.current.open) {
|
|
129
|
+
requested.current = false;
|
|
130
|
+
if (presentation === 'inline')
|
|
131
|
+
inline.current?.snapToIndex(activeIndex.current);
|
|
132
|
+
else {
|
|
133
|
+
focused.current = false;
|
|
134
|
+
sheet.current?.present();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else if (!dismissed.current) {
|
|
138
|
+
dismissed.current = true;
|
|
139
|
+
focus(latest.current.returnFocusRef?.current ?? null);
|
|
140
|
+
latest.current.onDismiss?.();
|
|
141
|
+
} });
|
|
142
|
+
}, [focus, presentation, requestClose]);
|
|
143
|
+
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 }) };
|
|
145
|
+
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
|
+
// Expose individual children instead of grouping the sheet as one adjustable element. Gorhom forwards only
|
|
147
|
+
// basic accessibility props, so modal escape and VoiceOver scope belong on its measured or scrolling content.
|
|
148
|
+
// Inline content keeps its native state while closed, with all descendants hidden from accessibility.
|
|
149
|
+
// 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 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 : [...fixedSnapPoints], 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: backgroundStyle ? [sheetFill, backgroundStyle] : sheetFill, handleIndicatorStyle: handleIndicatorStyle ? [{ backgroundColor: colors.action }, handleIndicatorStyle] : { backgroundColor: colors.action }, onChange: handleChange };
|
|
152
|
+
return presentation === 'inline' ? _jsx(BottomSheet, { ...backendProps, ref: inline, accessibilityElementsHidden: !open, importantForAccessibility: open ? 'auto' : 'no-hide-descendants', onClose: handleSettledClose, children: _jsx(Raised, { children: content }) }) : _jsx(BottomSheetModal, { ...backendProps, ref: sheet, enableDismissOnClose: true, stackBehavior: 'push', onDismiss: handleSettledClose, children: _jsx(Raised, { children: content }) });
|
|
153
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function SearchIcon({ color }: {
|
|
3
|
+
color: string;
|
|
4
|
+
}): React.JSX.Element;
|
|
5
|
+
/** Points down; the caller rotates it. */
|
|
6
|
+
export declare function ChevronIcon({ color }: {
|
|
7
|
+
color: string;
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
export declare function CloseIcon({ color }: {
|
|
10
|
+
color: string;
|
|
11
|
+
}): React.JSX.Element;
|
|
12
|
+
export type SeverityIconKind = 'info' | 'success' | 'warning' | 'error';
|
|
13
|
+
/** Shape as well as colour tells the severities apart: warning is a diamond, the others a circle with their own mark. */
|
|
14
|
+
export declare function SeverityIcon({ kind, color }: {
|
|
15
|
+
kind: SeverityIconKind;
|
|
16
|
+
color: string;
|
|
17
|
+
}): React.JSX.Element;
|
|
18
|
+
/** Neutral mark for an empty state: an empty tray. */
|
|
19
|
+
export declare function EmptyIcon({ color }: {
|
|
20
|
+
color: string;
|
|
21
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
/** Outline icons drawn from plain views, so status, field and navigation entries need no SVG peer. All are decorative: the control or text beside them carries the meaning. */
|
|
4
|
+
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', pointerEvents: 'none' };
|
|
5
|
+
const stroke = 1.75;
|
|
6
|
+
const centre = { alignItems: 'center', justifyContent: 'center' };
|
|
7
|
+
function Bar({ length, color, angle }) { return _jsx(View, { style: { position: 'absolute', width: length, height: stroke, borderRadius: stroke, backgroundColor: color, transform: [{ rotate: angle }] } }); }
|
|
8
|
+
export function SearchIcon({ color }) { return _jsxs(View, { ...hidden, style: { width: 18, height: 18 }, children: [_jsx(View, { style: { width: 13, height: 13, borderRadius: 7, borderWidth: stroke, borderColor: color } }), _jsx(View, { style: { position: 'absolute', right: 1, bottom: 3, width: 6, height: stroke, borderRadius: stroke, backgroundColor: color, transform: [{ rotate: '45deg' }] } })] }); }
|
|
9
|
+
/** Points down; the caller rotates it. */
|
|
10
|
+
export function ChevronIcon({ color }) { return _jsx(View, { ...hidden, style: { width: 20, height: 20, ...centre }, children: _jsx(View, { style: { width: 9, height: 9, borderRightWidth: stroke, borderBottomWidth: stroke, borderColor: color, transform: [{ translateY: -2 }, { rotate: '45deg' }] } }) }); }
|
|
11
|
+
export function CloseIcon({ color }) { return _jsxs(View, { ...hidden, style: { width: 20, height: 20, ...centre }, children: [_jsx(Bar, { length: 14, color: color, angle: '45deg' }), _jsx(Bar, { length: 14, color: color, angle: '-45deg' })] }); }
|
|
12
|
+
/** Shape as well as colour tells the severities apart: warning is a diamond, the others a circle with their own mark. */
|
|
13
|
+
export function SeverityIcon({ kind, color }) {
|
|
14
|
+
const mark = kind === 'success' ? _jsx(View, { style: { width: 9, height: 5, borderLeftWidth: stroke, borderBottomWidth: stroke, borderColor: color, transform: [{ translateY: -1 }, { rotate: '-45deg' }] } })
|
|
15
|
+
: kind === 'error' ? _jsxs(_Fragment, { children: [_jsx(Bar, { length: 9, color: color, angle: '45deg' }), _jsx(Bar, { length: 9, color: color, angle: '-45deg' })] })
|
|
16
|
+
: _jsxs(View, { style: { alignItems: 'center', gap: 1.5, flexDirection: kind === 'warning' ? 'column-reverse' : 'column' }, children: [_jsx(View, { style: { width: 2, height: 2, borderRadius: 1, backgroundColor: color } }), _jsx(View, { style: { width: 2, height: 6, borderRadius: 1, backgroundColor: color } })] });
|
|
17
|
+
return _jsxs(View, { ...hidden, style: { width: 20, height: 20, ...centre }, children: [kind === 'warning' ? _jsx(View, { style: { position: 'absolute', width: 15, height: 15, borderRadius: 4, borderWidth: stroke, borderColor: color, transform: [{ rotate: '45deg' }] } }) : _jsx(View, { style: { position: 'absolute', width: 20, height: 20, borderRadius: 10, borderWidth: stroke, borderColor: color } }), mark] });
|
|
18
|
+
}
|
|
19
|
+
/** Neutral mark for an empty state: an empty tray. */
|
|
20
|
+
export function EmptyIcon({ color }) { return _jsx(View, { ...hidden, style: { width: 48, height: 48, ...centre }, children: _jsx(View, { style: { width: 40, height: 30, borderRadius: 10, borderWidth: 2, borderColor: color, justifyContent: 'flex-end', alignItems: 'center', paddingBottom: 7 }, children: _jsx(View, { style: { width: 16, height: 2, borderRadius: 1, backgroundColor: color } }) }) }); }
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function Tabs({ label, items, value, defaultValue, onValueChange }: {
|
|
3
|
+
label: string;
|
|
4
|
+
items: readonly {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
content: React.ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}[];
|
|
10
|
+
value?: string;
|
|
11
|
+
defaultValue?: string;
|
|
12
|
+
onValueChange?: (v: string) => void;
|
|
13
|
+
}): React.JSX.Element;
|
|
14
|
+
/** 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. */
|
|
15
|
+
export declare function Accordion({ title, children, open, onOpenChange }: React.PropsWithChildren<{
|
|
16
|
+
title: string;
|
|
17
|
+
open?: boolean;
|
|
18
|
+
onOpenChange?: (v: boolean) => void;
|
|
19
|
+
}>): React.JSX.Element;
|
|
20
|
+
export declare function Navigation({ label, items }: {
|
|
21
|
+
label: string;
|
|
22
|
+
items: readonly {
|
|
23
|
+
label: string;
|
|
24
|
+
id: string;
|
|
25
|
+
active?: boolean;
|
|
26
|
+
onNavigate: () => void;
|
|
27
|
+
}[];
|
|
28
|
+
}): React.JSX.Element;
|
|
29
|
+
export declare const BottomNavigation: typeof Navigation;
|
|
30
|
+
export declare function Pagination({ page, total, onPageChange }: {
|
|
31
|
+
page: number;
|
|
32
|
+
total: number;
|
|
33
|
+
onPageChange: (p: number) => void;
|
|
34
|
+
}): React.JSX.Element;
|
|
35
|
+
export declare function Search({ query, onQueryChange, results, loading, error }: {
|
|
36
|
+
query: string;
|
|
37
|
+
onQueryChange: (s: string) => void;
|
|
38
|
+
results: readonly {
|
|
39
|
+
id: string;
|
|
40
|
+
label: string;
|
|
41
|
+
onSelect: () => void;
|
|
42
|
+
}[];
|
|
43
|
+
loading?: boolean;
|
|
44
|
+
error?: string;
|
|
45
|
+
}): React.JSX.Element;
|
|
46
|
+
export declare function BackButton({ onBack }: {
|
|
47
|
+
onBack: () => void;
|
|
48
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Animated, Easing, Pressable, View } from 'react-native';
|
|
4
|
+
import { tokens } from '@bloxwap/hig/tokens';
|
|
5
|
+
import { ChevronIcon } from './icons.js';
|
|
6
|
+
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
7
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
8
|
+
import { useColors, useControllable, useFills, useHIG } from './provider.js';
|
|
9
|
+
import { Button } from './button.js';
|
|
10
|
+
import { Text, Inline, Stack, Surface } from './surface.js';
|
|
11
|
+
import { Field, SearchInput } from './field.js';
|
|
12
|
+
/** Actions that sit side by side are 8dp apart; content keeps the 12dp gap. */
|
|
13
|
+
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 [current, set] = useControllable(value, defaultValue ?? items.find(item => !item.disabled)?.value ?? '', onValueChange); 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
|
+
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
|
+
/** 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
|
+
export function Accordion({ title, children, open, onOpenChange }) {
|
|
18
|
+
const [current, set] = useControllable(open, false, onOpenChange, 'disclosure');
|
|
19
|
+
const { reducedMotion, direction } = useHIG();
|
|
20
|
+
const colors = useColors();
|
|
21
|
+
const progress = useRef(new Animated.Value(current ? 1 : 0)).current;
|
|
22
|
+
const [height, setHeight] = useState(0);
|
|
23
|
+
const [mounted, setMounted] = useState(current);
|
|
24
|
+
const [settled, setSettled] = useState(true);
|
|
25
|
+
const first = useRef(true);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (first.current) {
|
|
28
|
+
first.current = false;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (reducedMotion) {
|
|
32
|
+
progress.stopAnimation();
|
|
33
|
+
progress.setValue(current ? 1 : 0);
|
|
34
|
+
setMounted(current);
|
|
35
|
+
setSettled(true);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (current)
|
|
39
|
+
setMounted(true);
|
|
40
|
+
setSettled(false);
|
|
41
|
+
// Height cannot run on the native driver; the chevron shares the value so both stay in step.
|
|
42
|
+
const animation = Animated.timing(progress, { toValue: current ? 1 : 0, duration: tokens.motion.base, easing: Easing.bezier(...tokens.easing.standard), useNativeDriver: false, isInteraction: false });
|
|
43
|
+
animation.start(({ finished }) => { if (finished) {
|
|
44
|
+
setSettled(true);
|
|
45
|
+
if (!current)
|
|
46
|
+
setMounted(false);
|
|
47
|
+
} });
|
|
48
|
+
return () => animation.stop();
|
|
49
|
+
}, [current, reducedMotion, progress]);
|
|
50
|
+
// Once open and at rest the content sizes itself again, so it can grow or shrink freely.
|
|
51
|
+
const clip = settled && current ? undefined : { height: progress.interpolate({ inputRange: [0, 1], outputRange: [0, height] }), overflow: 'hidden' };
|
|
52
|
+
return _jsxs(Surface, { style: { padding: 0 }, children: [_jsxs(Pressable, { accessibilityRole: 'button', accessibilityState: { expanded: current }, "aria-expanded": current, onPress: () => set(!current), style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: tokens.space.md, minHeight: 48, padding: tokens.space.xl, opacity: pressed ? .85 : 1 }), children: [_jsx(Text, { style: { flex: 1, minWidth: 0, fontWeight: '600' }, children: title }), _jsx(Animated.View, { style: { transform: [{ rotate: progress.interpolate({ inputRange: [0, 1], outputRange: ['0deg', '180deg'] }) }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] }), mounted && _jsx(Animated.View, { style: clip, children: _jsx(View, { onLayout: event => setHeight(event.nativeEvent.layout.height), style: { paddingHorizontal: tokens.space.xl, paddingBottom: tokens.space.xl }, children: children }) })] });
|
|
53
|
+
}
|
|
54
|
+
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
|
+
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 })] }); }
|
|
57
|
+
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
|
+
export function BackButton({ onBack }) { const { messages } = useHIG(); return _jsx(Button, { intent: 'secondary', onPress: onBack, children: messages.back ?? en.back }); }
|