@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.
Files changed (220) hide show
  1. package/LICENSE +5 -0
  2. package/README.md +44 -2
  3. package/chart/README.md +23 -0
  4. package/chart/dist/index.d.ts +8 -0
  5. package/chart/dist/index.js +12 -0
  6. package/contracts/README.md +3 -0
  7. package/contracts/dist/announcements.d.ts +12 -0
  8. package/contracts/dist/announcements.js +8 -0
  9. package/contracts/dist/feedback.d.ts +40 -0
  10. package/contracts/dist/feedback.js +1 -0
  11. package/contracts/dist/index.d.ts +41 -0
  12. package/contracts/dist/index.js +52 -0
  13. package/contracts/dist/messages.d.ts +300 -0
  14. package/contracts/dist/messages.js +114 -0
  15. package/css.d.ts +2 -0
  16. package/feedback/README.md +7 -0
  17. package/feedback/assets/error.wav +0 -0
  18. package/feedback/assets/manifest.json +78 -0
  19. package/feedback/assets/success.wav +0 -0
  20. package/feedback/assets/tick.wav +0 -0
  21. package/feedback/assets/toggle.wav +0 -0
  22. package/feedback/dist/browser-haptic.d.ts +23 -0
  23. package/feedback/dist/browser-haptic.js +41 -0
  24. package/feedback/dist/contract.d.ts +40 -0
  25. package/feedback/dist/contract.js +59 -0
  26. package/feedback/dist/native.d.ts +28 -0
  27. package/feedback/dist/native.js +63 -0
  28. package/feedback/dist/preferences.d.ts +8 -0
  29. package/feedback/dist/preferences.js +24 -0
  30. package/feedback/dist/presets.d.ts +57 -0
  31. package/feedback/dist/presets.js +1 -0
  32. package/feedback/dist/react.d.ts +19 -0
  33. package/feedback/dist/react.js +23 -0
  34. package/feedback/dist/web-haptic.d.ts +6 -0
  35. package/feedback/dist/web-haptic.js +6 -0
  36. package/feedback/dist/web-sound.d.ts +5 -0
  37. package/feedback/dist/web-sound.js +32 -0
  38. package/feedback/dist/web.d.ts +3 -0
  39. package/feedback/dist/web.js +4 -0
  40. package/native/README.md +16 -0
  41. package/native/android/build.gradle +28 -0
  42. package/native/android/src/main/java/com/bloxwap/hig/HIGAdjustableView.java +173 -0
  43. package/native/android/src/main/java/com/bloxwap/hig/HIGAdjustableViewManager.java +23 -0
  44. package/native/android/src/main/java/com/bloxwap/hig/HIGPackage.java +24 -0
  45. package/native/dist/animated-number-model.d.ts +24 -0
  46. package/native/dist/animated-number-model.js +110 -0
  47. package/native/dist/animated-number.d.ts +9 -0
  48. package/native/dist/animated-number.js +97 -0
  49. package/native/dist/brand.d.ts +7 -0
  50. package/native/dist/brand.js +7 -0
  51. package/native/dist/button.d.ts +30 -0
  52. package/native/dist/button.js +36 -0
  53. package/native/dist/checkbox.d.ts +3 -0
  54. package/native/dist/checkbox.js +11 -0
  55. package/native/dist/data.d.ts +57 -0
  56. package/native/dist/data.js +47 -0
  57. package/native/dist/field.d.ts +16 -0
  58. package/native/dist/field.js +26 -0
  59. package/native/dist/gesture-sheet.d.ts +73 -0
  60. package/native/dist/gesture-sheet.js +153 -0
  61. package/native/dist/icons.d.ts +21 -0
  62. package/native/dist/icons.js +20 -0
  63. package/native/dist/navigation.d.ts +48 -0
  64. package/native/dist/navigation.js +58 -0
  65. package/native/dist/overlay.d.ts +36 -0
  66. package/native/dist/overlay.js +65 -0
  67. package/native/dist/pickers.d.ts +54 -0
  68. package/native/dist/pickers.js +60 -0
  69. package/native/dist/provider.d.ts +62 -0
  70. package/native/dist/provider.js +67 -0
  71. package/native/dist/radio-group.d.ts +21 -0
  72. package/native/dist/radio-group.js +91 -0
  73. package/native/dist/recipes.d.ts +45 -0
  74. package/native/dist/recipes.js +32 -0
  75. package/native/dist/roles.d.ts +6 -0
  76. package/native/dist/roles.js +4 -0
  77. package/native/dist/select.d.ts +3 -0
  78. package/native/dist/select.js +9 -0
  79. package/native/dist/selection-types.d.ts +22 -0
  80. package/native/dist/selection-types.js +1 -0
  81. package/native/dist/selection.d.ts +8 -0
  82. package/native/dist/selection.js +7 -0
  83. package/native/dist/slider.d.ts +11 -0
  84. package/native/dist/slider.js +42 -0
  85. package/native/dist/status.d.ts +86 -0
  86. package/native/dist/status.js +112 -0
  87. package/native/dist/surface.d.ts +19 -0
  88. package/native/dist/surface.js +42 -0
  89. package/native/dist/swap-panel.d.ts +125 -0
  90. package/native/dist/swap-panel.js +177 -0
  91. package/native/dist/swap-parts.d.ts +86 -0
  92. package/native/dist/swap-parts.js +66 -0
  93. package/native/dist/swap-shared.d.ts +65 -0
  94. package/native/dist/swap-shared.js +76 -0
  95. package/native/dist/swap-sheet.d.ts +14 -0
  96. package/native/dist/swap-sheet.js +26 -0
  97. package/native/dist/swap-views.d.ts +41 -0
  98. package/native/dist/swap-views.js +37 -0
  99. package/native/dist/switch-row.d.ts +8 -0
  100. package/native/dist/switch-row.js +18 -0
  101. package/native/dist/switch.d.ts +10 -0
  102. package/native/dist/switch.js +30 -0
  103. package/native/dist/text-content.d.ts +5 -0
  104. package/native/dist/text-content.js +6 -0
  105. package/native/dist/wallet-address.d.ts +37 -0
  106. package/native/dist/wallet-address.js +50 -0
  107. package/native-fonts/README.md +17 -0
  108. package/native-fonts/dist/index.d.ts +164 -0
  109. package/native-fonts/dist/index.js +164 -0
  110. package/native-fonts/fonts/BloxwapMono-Bold.ttf +0 -0
  111. package/native-fonts/fonts/BloxwapMono-ExtraBold.ttf +0 -0
  112. package/native-fonts/fonts/BloxwapMono-Medium.ttf +0 -0
  113. package/native-fonts/fonts/BloxwapMono-SemiBold.ttf +0 -0
  114. package/native-fonts/fonts/BloxwapMono.ttf +0 -0
  115. package/native-fonts/fonts/BloxwapSans-Black.ttf +0 -0
  116. package/native-fonts/fonts/BloxwapSans-Bold.ttf +0 -0
  117. package/native-fonts/fonts/BloxwapSans-ExtraBold.ttf +0 -0
  118. package/native-fonts/fonts/BloxwapSans-Medium.ttf +0 -0
  119. package/native-fonts/fonts/BloxwapSans-SemiBold.ttf +0 -0
  120. package/native-fonts/fonts/BloxwapSans.ttf +0 -0
  121. package/native-fonts/fonts/BloxwapSansKR-SemiBold.ttf +0 -0
  122. package/native-fonts/fonts/BloxwapSansKR.ttf +0 -0
  123. package/native-fonts/fonts/BloxwapSansSC-SemiBold.ttf +0 -0
  124. package/native-fonts/fonts/BloxwapSansSC.ttf +0 -0
  125. package/native-fonts/fonts/OFL.txt +93 -0
  126. package/native-fonts/fonts/manifest.json +164 -0
  127. package/og-fonts/README.md +34 -0
  128. package/og-fonts/dist/index.d.ts +116 -0
  129. package/og-fonts/dist/index.js +102 -0
  130. package/og-fonts/dist/node.d.ts +11 -0
  131. package/og-fonts/dist/node.js +39 -0
  132. package/og-fonts/fonts/BloxwapMono-Medium.ttf +0 -0
  133. package/og-fonts/fonts/BloxwapSans-Black.ttf +0 -0
  134. package/og-fonts/fonts/BloxwapSans-Bold.ttf +0 -0
  135. package/og-fonts/fonts/BloxwapSans-Medium.ttf +0 -0
  136. package/og-fonts/fonts/BloxwapSans.ttf +0 -0
  137. package/og-fonts/fonts/OFL.txt +93 -0
  138. package/og-fonts/fonts/manifest.json +65 -0
  139. package/package.json +476 -4
  140. package/react/README.md +30 -0
  141. package/react/dist/animated-number-model.d.ts +20 -0
  142. package/react/dist/animated-number-model.js +92 -0
  143. package/react/dist/animated-number.d.ts +8 -0
  144. package/react/dist/animated-number.js +72 -0
  145. package/react/dist/base.css +9 -0
  146. package/react/dist/brand.d.ts +7 -0
  147. package/react/dist/brand.js +5 -0
  148. package/react/dist/button.d.ts +14 -0
  149. package/react/dist/button.js +20 -0
  150. package/react/dist/data.d.ts +78 -0
  151. package/react/dist/data.js +36 -0
  152. package/react/dist/dialog.d.ts +29 -0
  153. package/react/dist/dialog.js +21 -0
  154. package/react/dist/field.d.ts +16 -0
  155. package/react/dist/field.js +20 -0
  156. package/react/dist/gesture-sheet.d.ts +41 -0
  157. package/react/dist/gesture-sheet.js +128 -0
  158. package/react/dist/navigation.d.ts +48 -0
  159. package/react/dist/navigation.js +69 -0
  160. package/react/dist/notify.d.ts +14 -0
  161. package/react/dist/notify.js +6 -0
  162. package/react/dist/overlay.d.ts +17 -0
  163. package/react/dist/overlay.js +18 -0
  164. package/react/dist/provider.d.ts +25 -0
  165. package/react/dist/provider.js +50 -0
  166. package/react/dist/recipes/activity-list.d.ts +8 -0
  167. package/react/dist/recipes/activity-list.js +6 -0
  168. package/react/dist/recipes/balance-card.d.ts +6 -0
  169. package/react/dist/recipes/balance-card.js +5 -0
  170. package/react/dist/recipes/code-window.d.ts +4 -0
  171. package/react/dist/recipes/code-window.js +4 -0
  172. package/react/dist/recipes/install-command.d.ts +6 -0
  173. package/react/dist/recipes/install-command.js +15 -0
  174. package/react/dist/recipes/market-row.d.ts +25 -0
  175. package/react/dist/recipes/market-row.js +8 -0
  176. package/react/dist/recipes/marketing-hero.d.ts +7 -0
  177. package/react/dist/recipes/marketing-hero.js +5 -0
  178. package/react/dist/recipes/pickers.d.ts +57 -0
  179. package/react/dist/recipes/pickers.js +78 -0
  180. package/react/dist/recipes/swap/amount-card.d.ts +40 -0
  181. package/react/dist/recipes/swap/amount-card.js +7 -0
  182. package/react/dist/recipes/swap/picker.d.ts +26 -0
  183. package/react/dist/recipes/swap/picker.js +20 -0
  184. package/react/dist/recipes/swap/settings.d.ts +24 -0
  185. package/react/dist/recipes/swap/settings.js +25 -0
  186. package/react/dist/recipes/swap/shared.d.ts +98 -0
  187. package/react/dist/recipes/swap/shared.js +106 -0
  188. package/react/dist/recipes/swap-panel.d.ts +127 -0
  189. package/react/dist/recipes/swap-panel.js +170 -0
  190. package/react/dist/recipes/swap-sheet.d.ts +16 -0
  191. package/react/dist/recipes/swap-sheet.js +22 -0
  192. package/react/dist/recipes/trade-entry.d.ts +11 -0
  193. package/react/dist/recipes/trade-entry.js +12 -0
  194. package/react/dist/recipes.d.ts +10 -0
  195. package/react/dist/recipes.js +11 -0
  196. package/react/dist/select.d.ts +4 -0
  197. package/react/dist/select.js +174 -0
  198. package/react/dist/selection.d.ts +40 -0
  199. package/react/dist/selection.js +23 -0
  200. package/react/dist/slider.d.ts +11 -0
  201. package/react/dist/slider.js +10 -0
  202. package/react/dist/status.d.ts +63 -0
  203. package/react/dist/status.js +47 -0
  204. package/react/dist/styles.css +542 -0
  205. package/react/dist/surface.d.ts +291 -0
  206. package/react/dist/surface.js +9 -0
  207. package/react/dist/toast.d.ts +17 -0
  208. package/react/dist/toast.js +21 -0
  209. package/react/dist/wallet-address.d.ts +23 -0
  210. package/react/dist/wallet-address.js +24 -0
  211. package/tokens/README.md +17 -0
  212. package/tokens/assets/bloxwap-icon.svg +1 -0
  213. package/tokens/dist/brand.d.ts +19 -0
  214. package/tokens/dist/brand.js +24 -0
  215. package/tokens/dist/index.d.ts +437 -0
  216. package/tokens/dist/index.js +514 -0
  217. package/tokens/dist/manifest.json +200 -0
  218. package/tokens/dist/theme.d.ts +11 -0
  219. package/tokens/dist/theme.js +22 -0
  220. package/tokens/dist/tokens.css +120 -0
@@ -0,0 +1,36 @@
1
+ import type { GestureResponderEvent, ModalProps, StyleProp, ViewProps, ViewStyle } from 'react-native';
2
+ import React from 'react';
3
+ import { Text as RNText, TextInput, View } from 'react-native';
4
+ export interface DialogProps {
5
+ open: boolean;
6
+ onOpenChange: (open: boolean) => void;
7
+ title: string;
8
+ description?: string;
9
+ children: React.ReactNode;
10
+ initialFocusRef?: React.RefObject<React.ComponentRef<typeof View> | React.ComponentRef<typeof RNText> | React.ComponentRef<typeof TextInput> | null>;
11
+ returnFocusRef?: React.RefObject<React.ComponentRef<typeof View> | React.ComponentRef<typeof RNText> | React.ComponentRef<typeof TextInput> | null>;
12
+ /** Close button text and accessible name; defaults to HIGProvider `messages.close`. */ closeLabel?: string;
13
+ /** Custom content owns its visible heading, actions, padding and scrolling. The native Modal remains HIG-owned. */ contentMode?: 'default' | 'custom';
14
+ /** Accessible caller heading used when custom content renders the title. Otherwise HIG keeps a visually hidden title. */ titleRef?: React.RefObject<React.ComponentRef<typeof View> | React.ComponentRef<typeof RNText> | React.ComponentRef<typeof TextInput> | null>;
15
+ /** Custom-mode stage inside the Modal, for example GestureHandlerRootView on Android. */ stageComponent?: React.ComponentType<ViewProps>;
16
+ stageStyle?: StyleProp<ViewStyle>;
17
+ stageTestID?: string;
18
+ /** Custom-mode backdrop, including the host's dismissal policy and decoration. */ backdrop?: React.ReactNode;
19
+ /** Custom-mode surface layout; no implicit padding or scroll view is added. */ contentStyle?: StyleProp<ViewStyle>;
20
+ /** Identifies the actual modal content surface in either mode. */ testID?: string;
21
+ /** Native Modal animation. Reduced motion always selects `none`; the default stays `none`. */ animationType?: ModalProps['animationType'];
22
+ }
23
+ export declare function Dialog({ open, onOpenChange, title, description, children, initialFocusRef, returnFocusRef, closeLabel, contentMode, titleRef, stageComponent: Stage, stageStyle, stageTestID, backdrop, contentStyle, testID, animationType }: DialogProps): React.JSX.Element;
24
+ export declare const Sheet: typeof Dialog;
25
+ export declare const AlertDialog: typeof Dialog;
26
+ export declare function Menu({ label, items, closeLabel }: {
27
+ label: string;
28
+ items: readonly {
29
+ label: string;
30
+ disabled?: boolean;
31
+ onSelect: (event: GestureResponderEvent) => void;
32
+ }[]; /** Close button text and accessible name; defaults to HIGProvider `messages.close`. */
33
+ closeLabel?: string;
34
+ }): React.JSX.Element;
35
+ /** Touch alternative to popover/hover tooltip: persistent help text. */
36
+ export declare function HelpText({ children }: React.PropsWithChildren): React.JSX.Element;
@@ -0,0 +1,65 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as en from '@bloxwap/hig/contracts/messages';
3
+ import { Raised, useColors, useHIG } from './provider.js';
4
+ import React, { useEffect, useRef, useId, useCallback } from 'react';
5
+ import { Modal, KeyboardAvoidingView, Platform, ScrollView, AccessibilityInfo, findNodeHandle, View } from 'react-native';
6
+ import { SafeAreaView } from 'react-native-safe-area-context';
7
+ import { Heading, Text, Stack } from './surface.js';
8
+ import { Button } from './button.js';
9
+ /** The panel has no stroke: it is the `overlay` fill, darker than a card, lifted by a soft shadow. Native focus requests remain best effort; host supplies a live trigger ref for restoration. */
10
+ /** Android TalkBack ignores the TYPE_VIEW_FOCUSED event behind setAccessibilityFocus in RN 0.81 Fabric (emulator: focus fell back to the first screen element); a hover-enter event moves its focus. */
11
+ function focusNative(target) { if (Platform.OS === 'web' || !target)
12
+ return; const handle = findNodeHandle(target); if (handle == null)
13
+ return; AccessibilityInfo.setAccessibilityFocus(handle); if (Platform.OS === 'android')
14
+ AccessibilityInfo.sendAccessibilityEvent(target, 'viewHoverEnter'); }
15
+ /** React Native's iOS Modal defaults to portrait only; opening an overlay must not rotate a landscape host. */
16
+ const overlayOrientations = ['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right'];
17
+ export function Dialog({ open, onOpenChange, title, description, children, initialFocusRef, returnFocusRef, closeLabel, contentMode = 'default', titleRef, stageComponent: Stage = View, stageStyle, stageTestID, backdrop, contentStyle, testID, animationType = 'none' }) {
18
+ const { messages, reducedMotion, direction } = useHIG();
19
+ const colors = useColors();
20
+ const heading = useRef(null);
21
+ const previous = useRef(open);
22
+ const latest = useRef({ open, returnFocusRef });
23
+ latest.current = { open, returnFocusRef };
24
+ const returnPending = useRef(false), frame = useRef(undefined);
25
+ const resolvedAnimation = reducedMotion ? 'none' : animationType;
26
+ const restoreFocus = useCallback(() => {
27
+ if (latest.current.open || !returnPending.current || frame.current !== undefined)
28
+ return;
29
+ frame.current = requestAnimationFrame(() => { frame.current = undefined; if (!latest.current.open && returnPending.current) {
30
+ returnPending.current = false;
31
+ focusNative(latest.current.returnFocusRef?.current ?? null);
32
+ } });
33
+ }, []);
34
+ useEffect(() => {
35
+ const wasOpen = previous.current;
36
+ previous.current = open;
37
+ if (frame.current !== undefined) {
38
+ cancelAnimationFrame(frame.current);
39
+ frame.current = undefined;
40
+ }
41
+ if (open)
42
+ returnPending.current = false;
43
+ else {
44
+ if (wasOpen)
45
+ returnPending.current = true;
46
+ if (Platform.OS !== 'ios' || resolvedAnimation === 'none')
47
+ restoreFocus();
48
+ }
49
+ }, [open, resolvedAnimation, restoreFocus]);
50
+ useEffect(() => () => { if (frame.current !== undefined)
51
+ cancelAnimationFrame(frame.current); returnPending.current = false; }, []);
52
+ const modal = _jsx(Modal, { visible: open, transparent: true, animationType: resolvedAnimation, supportedOrientations: overlayOrientations, onShow: () => { if (latest.current.open)
53
+ focusNative(initialFocusRef?.current ?? (contentMode === 'custom' ? titleRef?.current : null) ?? heading.current); }, onDismiss: restoreFocus, onRequestClose: () => onOpenChange(false), accessibilityViewIsModal: true, children: contentMode === 'custom' ? _jsxs(Stage, { style: [{ flex: 1, backgroundColor: '#000b', justifyContent: 'center', direction }, stageStyle], testID: stageTestID, children: [backdrop, _jsxs(View, { accessible: false, accessibilityLabel: title, accessibilityViewIsModal: true, onAccessibilityEscape: () => onOpenChange(false), collapsable: false, style: [{ direction }, contentStyle], testID: testID, children: [!titleRef && _jsx(Heading, { ref: heading, accessible: true, accessibilityLabel: title, style: { position: 'absolute', width: 1, height: 1, overflow: 'hidden' }, children: title }), _jsx(Raised, { children: children })] })] }) : _jsx(SafeAreaView, { style: { flex: 1, backgroundColor: '#000b', justifyContent: 'center' }, children: _jsx(KeyboardAvoidingView, { behavior: Platform.OS === 'ios' ? 'padding' : 'height', style: { maxHeight: '90%' }, children: _jsx(ScrollView, { testID: testID, keyboardShouldPersistTaps: 'handled', contentContainerStyle: { padding: 24, backgroundColor: colors.overlay, borderRadius: 14, boxShadow: '0 16px 48px #0008' }, children: _jsx(Raised, { children: _jsxs(Stack, { children: [_jsx(Heading, { ref: heading, children: title }), description !== undefined && _jsx(Text, { children: description }), children, _jsx(Button, { intent: 'secondary', suppressFeedback: true, style: { marginTop: 4 }, onPress: () => onOpenChange(false), children: closeLabel ?? messages.close ?? en.close })] }) }) }) }) }) });
54
+ return modal;
55
+ }
56
+ export const Sheet = Dialog;
57
+ export const AlertDialog = Dialog;
58
+ export function Menu({ label, items, closeLabel }) { const [open, setOpen] = React.useState(false); const { feedback, messages } = useHIG(); const id = useId(); const sequence = useRef(0); const trigger = useRef(null); return _jsxs(_Fragment, { children: [_jsx(Button, { ref: trigger, intent: 'secondary', suppressFeedback: true, onPress: () => setOpen(true), children: label }), _jsx(Dialog, { open: open, onOpenChange: setOpen, title: label, description: messages.menuDescription ?? en.menuDescription, closeLabel: closeLabel, returnFocusRef: trigger, children: items.map((item, i) => _jsx(Button, { disabled: item.disabled, suppressFeedback: true, intent: 'secondary', onPress: event => { if (item.disabled)
59
+ return; item.onSelect(event); if (event.isDefaultPrevented())
60
+ return; setOpen(false); try {
61
+ feedback?.emit({ id: `${id}/${++sequence.current}`, source: id, intent: 'selection', origin: 'native' });
62
+ }
63
+ catch { /* Optional feedback cannot alter the action. */ } }, children: item.label }, i)) })] }); }
64
+ /** Touch alternative to popover/hover tooltip: persistent help text. */
65
+ export function HelpText({ children }) { return _jsx(Text, { children: children }); }
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import { type StyleProp, type ViewStyle } from 'react-native';
3
+ import { type SwapChain, type SwapToken, type SwapWallet } from './swap-shared.js';
4
+ export type { SwapChain, SwapToken, SwapWallet } from './swap-shared.js';
5
+ /** The searchable token list both pickers share. */
6
+ export interface PickerListProps {
7
+ /** Tokens offered: a wallet's holdings, a whitelist, or a whole catalog. */
8
+ tokens: readonly SwapToken[];
9
+ /** Chain filter options. Derived from the tokens, in first-seen order, when omitted. */
10
+ chains?: readonly SwapChain[];
11
+ /** `false` leaves out the chain filter, for a list on one chain or one that should not be narrowed by chain. */
12
+ chainFilter?: boolean;
13
+ /** Token ids for a Hot section at the top of the unfiltered list, in rank order. */
14
+ hotTokenIds?: readonly string[];
15
+ selected?: SwapToken | null;
16
+ onSelect: (token: SwapToken) => void;
17
+ /** Shows the loading text in place of the empty text while the list is empty. */
18
+ loading?: boolean;
19
+ /** Web only: focuses the search with a hardware pointer. Native never raises the keyboard on mount. */
20
+ autoFocus?: boolean;
21
+ }
22
+ export interface FromPickerProps extends PickerListProps {
23
+ /** The connected wallet. Omit for a list with no wallet row at all. */
24
+ wallet?: SwapWallet;
25
+ /** Shows Connect wallet while no wallet is connected. */
26
+ onConnect?: () => void;
27
+ /** Shows the disconnect button beside a connected wallet. Omit it where signing out does not belong. */
28
+ onDisconnect?: () => void;
29
+ /** The Generate address switch, offered while no wallet is connected: the user picks a chain and an asset and the host shows an address to send it to. Omit `onGenerateAddressChange` to hide it. */
30
+ generateAddress?: boolean;
31
+ onGenerateAddressChange?: (generate: boolean) => void;
32
+ style?: StyleProp<ViewStyle>;
33
+ }
34
+ /**
35
+ * Where the assets come from. A connected wallet shows its address, with a disconnect button the host can leave out, above
36
+ * the tokens it holds (or a whitelist). With no wallet it offers Connect wallet and a Generate address switch above the list.
37
+ * The host owns the wallet, the token data and the generated address.
38
+ */
39
+ export declare function FromPicker({ wallet, onConnect, onDisconnect, generateAddress, onGenerateAddressChange, style, ...list }: FromPickerProps): React.JSX.Element;
40
+ export interface ToPickerProps extends Partial<PickerListProps> {
41
+ /** The destination address field. Omit `onAddressChange` to hide it. */
42
+ address?: string;
43
+ onAddressChange?: (address: string) => void;
44
+ /** Shown while the field is empty, for example the connected wallet shortened; defaults to the built-in label. */
45
+ addressPlaceholder?: string;
46
+ /** Shows the scan button. HIG ships no scanner: the host opens its own and writes the result to `address`. */
47
+ onScan?: () => void;
48
+ style?: StyleProp<ViewStyle>;
49
+ }
50
+ /**
51
+ * Where the assets go. On its own it is a destination address field with a scan button. With `tokens` it adds the
52
+ * searchable token list, with the chain filter or, with `chainFilter={false}`, without it.
53
+ */
54
+ export declare function ToPicker({ address, onAddressChange, addressPlaceholder, onScan, style, tokens, onSelect, ...list }: ToPickerProps): React.JSX.Element;
@@ -0,0 +1,60 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useContext, useMemo, useState } from 'react';
3
+ import { FlatList, Pressable, View, useWindowDimensions } from 'react-native';
4
+ import { formatNumber } from '@bloxwap/hig/contracts';
5
+ import { useColors, useFills, useHIG, useMessages } from './provider.js';
6
+ import { Text } from './surface.js';
7
+ import { Button, IconButton } from './button.js';
8
+ import { Input, SearchInput } from './field.js';
9
+ import { Filter } from './radio-group.js';
10
+ import { SwitchRow } from './switch-row.js';
11
+ import { LeaveIcon, LockIcon, ScanIcon, SwapHostContext, TokenIcon, WalletIcon } from './swap-parts.js';
12
+ import { addressColor, pickerRows, shortAddress } from './swap-shared.js';
13
+ /** Chains present in a token list, in first-seen order. */
14
+ function chainsOf(tokens) { const seen = new Map(); for (const token of tokens)
15
+ if (!seen.has(token.chainId))
16
+ seen.set(token.chainId, { chainId: token.chainId, name: token.chain, icon: token.chainIcon }); return [...seen.values()]; }
17
+ function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected = null, onSelect, loading, side, title }) {
18
+ const { locale, direction } = useHIG();
19
+ const colors = useColors();
20
+ const fills = useFills();
21
+ const t = useMessages();
22
+ const window = useWindowDimensions();
23
+ // A sheet passes its backend's list through the host context so drags hand off to the sheet.
24
+ const List = useContext(SwapHostContext).listComponent ?? FlatList;
25
+ const [query, setQuery] = useState('');
26
+ const [chain, pickChain] = useState('');
27
+ const options = useMemo(() => chains ?? chainsOf(tokens), [chains, tokens]);
28
+ // The filter speaks in strings; an empty value is every chain.
29
+ const chainId = chain === '' ? null : options.find(item => String(item.chainId) === chain)?.chainId ?? null;
30
+ const { rows, hotCount } = useMemo(() => pickerRows(tokens, query, chainId, hotTokenIds), [tokens, hotTokenIds, query, chainId]);
31
+ const section = (heading) => _jsx(Text, { accessibilityRole: 'header', style: { paddingHorizontal: 8, paddingTop: 12, paddingBottom: 6, fontSize: 12, lineHeight: 18, fontWeight: '600', letterSpacing: 1, textTransform: 'uppercase', color: colors.muted }, children: heading });
32
+ const chainOptions = useMemo(() => [{ value: '', label: t.swapAllChains }, ...options.map(item => ({ value: String(item.chainId), label: item.name, icon: item.icon }))], [options, t.swapAllChains]);
33
+ const empty = _jsx(Text, { accessibilityLiveRegion: 'polite', testID: `swap-empty-${side}`, style: { paddingVertical: 32, textAlign: 'center', fontSize: 14, lineHeight: 21, color: colors.muted }, children: loading ? `${t.loading}…` : t.swapNoTokens });
34
+ return _jsxs(_Fragment, { children: [_jsx(SearchInput, { accessibilityLabel: t.swapSearchTokens, placeholder: t.swapSearchTokens, testID: `swap-search-${side}`, value: query, onChangeText: setQuery, autoCapitalize: 'none', autoCorrect: false, autoComplete: 'off', spellCheck: false }), chainFilter && options.length > 1 ? _jsx(Filter, { label: t.swapChains, options: chainOptions, value: chain, onValueChange: pickChain }) : null, _jsx(List, { style: { height: Math.max(240, Math.round(window.height * 0.5)) }, data: rows, keyExtractor: token => token.id, keyboardShouldPersistTaps: 'handled', accessibilityLabel: title, testID: `swap-list-${side}`, initialNumToRender: 12, ListEmptyComponent: empty, renderItem: ({ item: token, index }) => {
35
+ const isSelected = selected?.id === token.id, balance = token.balance ?? 0, price = token.price ?? 0;
36
+ return _jsxs(View, { children: [hotCount > 0 && index === 0 ? section(t.swapHot) : null, hotCount > 0 && index === hotCount ? section(t.swapAllTokens) : null, _jsxs(Pressable, { accessibilityRole: 'button', accessibilityState: { selected: isSelected }, testID: `swap-token-${token.id}`, onPress: () => onSelect(token), style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', gap: 12, marginBottom: 4, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 9999, backgroundColor: pressed ? fills.well : 'transparent', opacity: isSelected ? 0.5 : 1 }), children: [_jsx(TokenIcon, { token: token }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: token.name }), _jsxs(Text, { style: { fontSize: 14, lineHeight: 21, color: colors.muted }, children: [token.chain, isSelected ? ` · ${t.swapSelected}` : ''] })] }), balance > 0 ? _jsxs(View, { style: { alignItems: 'flex-end' }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: formatNumber(balance, locale, { maximumFractionDigits: 6 }) }), price > 0 ? _jsx(Text, { style: { fontSize: 14, lineHeight: 21, color: colors.muted }, children: formatNumber(balance * price, locale, { style: 'currency', currency: 'USD' }) }) : null] }) : null] })] });
37
+ } })] });
38
+ }
39
+ /**
40
+ * Where the assets come from. A connected wallet shows its address, with a disconnect button the host can leave out, above
41
+ * the tokens it holds (or a whitelist). With no wallet it offers Connect wallet and a Generate address switch above the list.
42
+ * The host owns the wallet, the token data and the generated address.
43
+ */
44
+ export function FromPicker({ wallet, onConnect, onDisconnect, generateAddress = false, onGenerateAddressChange, style, ...list }) {
45
+ const colors = useColors();
46
+ const fills = useFills();
47
+ const t = useMessages();
48
+ return _jsxs(View, { accessibilityLabel: t.swapFrom, testID: 'from-picker', style: [{ gap: 16 }, style], children: [wallet?.connected ?
49
+ _jsxs(View, { testID: 'picker-wallet', style: { flexDirection: 'row', alignItems: 'stretch', gap: 8 }, children: [_jsxs(View, { style: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 48, paddingVertical: 8, paddingHorizontal: 16, borderRadius: 9999, backgroundColor: fills.well }, children: [_jsx(View, { style: { width: 28, height: 28, borderRadius: 14, backgroundColor: addressColor(wallet.address ?? '') } }), _jsx(Text, { numberOfLines: 1, style: { flex: 1, fontWeight: '600' }, children: wallet.address ? shortAddress(wallet.address) : '' }), _jsx(LockIcon, { color: colors.muted })] }), onDisconnect ? _jsx(IconButton, { intent: 'secondary', label: t.swapDisconnect, testID: 'picker-disconnect', onPress: onDisconnect, style: { minWidth: 48, minHeight: 48 }, children: _jsx(LeaveIcon, { color: colors.text }) }) : null] })
50
+ : wallet && (onConnect || onGenerateAddressChange) ? _jsxs(View, { testID: 'picker-connect-row', style: { flexDirection: 'row', alignItems: 'stretch', gap: 8 }, children: [onConnect ? _jsxs(Button, { testID: 'picker-connect', onPress: onConnect, style: { flex: 1, alignSelf: 'auto' }, children: [_jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: _jsx(WalletIcon, { color: colors.onAction }) }, 'icon'), t.swapConnectWallet] }) : null, onGenerateAddressChange ? _jsx(SwitchRow, { label: t.swapGenerateAddress, checked: generateAddress, onCheckedChange: onGenerateAddressChange, testID: 'picker-generate', style: { flex: onConnect ? undefined : 1, minHeight: 44, alignItems: 'center', paddingStart: 16, paddingEnd: 12, borderRadius: 9999, backgroundColor: fills.well }, children: _jsxs(View, { style: { flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12 }, children: [_jsx(Text, { numberOfLines: 1, style: { fontWeight: '500' }, children: t.swapGenerateAddress }), _jsx(View, { style: { width: 40, height: 24, borderRadius: 12, padding: 3, backgroundColor: generateAddress ? colors.action : colors.border, alignItems: generateAddress ? 'flex-end' : 'flex-start' }, children: _jsx(View, { style: { width: 18, height: 18, borderRadius: 9, backgroundColor: generateAddress ? colors.onAction : colors.text } }) })] }) }) : null] }) : null, _jsx(TokenList, { ...list, side: 'from', title: t.swapFrom })] });
51
+ }
52
+ /**
53
+ * Where the assets go. On its own it is a destination address field with a scan button. With `tokens` it adds the
54
+ * searchable token list, with the chain filter or, with `chainFilter={false}`, without it.
55
+ */
56
+ export function ToPicker({ address, onAddressChange, addressPlaceholder, onScan, style, tokens, onSelect, ...list }) {
57
+ const colors = useColors();
58
+ const t = useMessages();
59
+ return _jsxs(View, { accessibilityLabel: t.swapTo, testID: 'to-picker', style: [{ gap: 16 }, style], children: [onAddressChange ? _jsxs(View, { testID: 'picker-address-row', style: { flexDirection: 'row', alignItems: 'center', gap: 8 }, children: [_jsx(View, { style: { flex: 1 }, children: _jsx(Input, { accessibilityLabel: t.swapRecipient, placeholder: addressPlaceholder ?? t.swapRecipient, testID: 'picker-address', value: address ?? '', onChangeText: onAddressChange, autoCapitalize: 'none', autoCorrect: false, autoComplete: 'off', spellCheck: false }) }), onScan ? _jsx(IconButton, { intent: 'secondary', label: t.swapScan, testID: 'picker-scan', onPress: onScan, style: { minWidth: 48, minHeight: 48 }, children: _jsx(ScanIcon, { color: colors.text }) }) : null] }) : null, tokens && onSelect ? _jsx(TokenList, { ...list, tokens: tokens, onSelect: onSelect, side: 'to', title: t.swapTo }) : null] });
60
+ }
@@ -0,0 +1,62 @@
1
+ import type { FeedbackSink, FeedbackIntent } from '@bloxwap/hig/contracts/feedback';
2
+ import React from 'react';
3
+ import { nativeSrgb } from '@bloxwap/hig/tokens';
4
+ import { type Environment } from '@bloxwap/hig/contracts';
5
+ import { type HIGMessages } from '@bloxwap/hig/contracts/messages';
6
+ export type { HIGMessages } from '@bloxwap/hig/contracts/messages';
7
+ /** Direction of a host-supplied locale (for example expo-localization's `getLocales()[0]`) for `HIGProvider direction`; see #86. */
8
+ export { localeDirection, type HostLocale } from '@bloxwap/hig/contracts';
9
+ /** Colour space the host paints React Native colours in. `display-p3` is for iOS hosts whose React Native default colour space is Display P3 (an app delegate `defaultColorSpace()` override); there HIG paints its generated `nativeDisplayP3` table (`nativeColors.iosDisplayP3`). Android and web stay sRGB, because HIG publishes no other table for them. */
10
+ export type HIGColorSpace = 'srgb' | 'display-p3';
11
+ /** Roles of HIG's generated colour tables (`colorTable`). */
12
+ export type HIGTableColorRole = keyof typeof nativeSrgb;
13
+ /** Market-direction roles: `up` (rising, long, gain) and `down` (falling, short, loss). They default to `buy` and `sell`; `HIGProvider marketColors` overrides them. */
14
+ export type HIGMarketColorRole = 'up' | 'down';
15
+ /** Semantic token roles every native component paints from. */
16
+ export type HIGColorRole = HIGTableColorRole | HIGMarketColorRole;
17
+ /** Native colour roles, including any provider primary colour and market colour override. */
18
+ export type HIGColors = Readonly<Record<HIGColorRole, string>>;
19
+ /** Host colours for the market-direction roles, in the provider's colour space (for example `#rrggbb` Display P3 channels on an iOS P3 host). An omitted role keeps `buy`/`sell`. */
20
+ export interface HIGMarketColors {
21
+ up?: string;
22
+ down?: string;
23
+ }
24
+ /** HIG's table for a colour space and platform: `nativeDisplayP3` for `display-p3` on iOS, sRGB everywhere else (including unknown values from untyped JS). */
25
+ export declare function colorTable(colorSpace?: HIGColorSpace, os?: string): Readonly<Record<HIGTableColorRole, string>>;
26
+ export interface HIGContext extends Environment {
27
+ primaryColor?: string; /** Market-direction colours for `up`/`down`; inherited by nested providers, like `primaryColor`. */
28
+ marketColors?: HIGMarketColors;
29
+ onAccepted?: (id: string) => void;
30
+ feedback?: FeedbackSink;
31
+ fontFamily?: string;
32
+ fontFamilies?: Readonly<Record<string, string>>; /** Registered static companion faces by script and weight. Text selects the detected script and nearest registered weight. */
33
+ fontFamiliesByScript?: Readonly<Partial<Record<'latin' | 'ko' | 'zh', Readonly<Record<string, string>>>>>; /** Registered monospace face for code/commands, e.g. BloxwapMonoRegular. */
34
+ monoFontFamily?: string; /** Default Dynamic Type / font-scale cap for HIG Text; a Text prop overrides it. Leave unset for prose. */
35
+ maxFontSizeMultiplier?: number; /** Per-script letter spacing in em for Korean and Chinese companion faces; overrides `scriptLetterSpacing`. */
36
+ letterSpacingByScript?: Readonly<Partial<Record<'ko' | 'zh', number>>>; /** Colour space HIG paints in; defaults to `srgb` and is inherited by nested providers. Read the resolved table with `useColors()`. */
37
+ colorSpace: HIGColorSpace; /** Host translations of built-in copy, merged through nested providers. Components fall back to the English export per key; read the full resolved catalog with `useMessages()`. */
38
+ messages: Readonly<Partial<HIGMessages>>;
39
+ }
40
+ export interface HIGProviderProps extends Partial<Omit<HIGContext, 'messages'>> {
41
+ colorSpace?: HIGColorSpace; /** Translations for HIG's built-in strings; omitted keys fall back to the enclosing provider, then English. */
42
+ messages?: Partial<HIGMessages>;
43
+ }
44
+ /** Direction defaults to the OS layout direction (I18nManager) so HIG roots never force LTR inside an RTL app. React Native 0.83 Android does not report a per-app RTL locale through I18nManager (#86): RTL hosts pass `direction={localeDirection(getLocales()[0])}`. Hosts that disallow RTL leave `direction` unset. */
45
+ export declare function HIGProvider({ children, density, locale, direction, reducedMotion, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace, primaryColor, marketColors, messages }: React.PropsWithChildren<HIGProviderProps>): React.JSX.Element;
46
+ export declare const useHIG: () => HIGContext;
47
+ /** Marks content that sits on a Surface, Dialog or sheet. HIG has no resting strokes, so wells inside step up one fill to stay visible. */
48
+ export declare function Raised({ children }: React.PropsWithChildren): React.JSX.Element;
49
+ /** Fills for the current elevation: `well` for inputs, tracks and neutral chips; `raised` for what sits on a well (a selected segment). On the page they are `surface` and `nested`; inside a Surface, Dialog or sheet, `nested` and `border`. */
50
+ export declare function useFills(): {
51
+ well: string;
52
+ raised: string;
53
+ };
54
+ /** The nearest HIGProvider's colour table (sRGB by default). Every HIG native component paints through this; hosts may read it for their own views. */
55
+ export declare function useColors(): HIGColors;
56
+ /** Approved Bloxwap brand colours in the host's colour space, independent of a product accent. */
57
+ /** The colour space this subtree actually paints in: `display-p3` only when a provider asked for it on iOS, as in `colorTable`; otherwise `srgb`. */
58
+ export declare function useColorSpace(): HIGColorSpace;
59
+ export declare function useBrandColors(): Readonly<Record<HIGTableColorRole, string>>;
60
+ /** Complete built-in copy for the nearest HIGProvider: host translations over the English defaults. */
61
+ export declare function useMessages(): HIGMessages;
62
+ export declare function useControllable<T>(value: T | undefined, initial: T, onChange?: (value: T) => void, intent?: FeedbackIntent): [T, (next: T) => void];
@@ -0,0 +1,67 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useEffect, useMemo, useState, useRef, useId } from 'react';
3
+ import { AccessibilityInfo, I18nManager, Platform } from 'react-native';
4
+ import { nativeSrgb, nativeDisplayP3, resolvePrimaryColor } from '@bloxwap/hig/tokens';
5
+ import { defaultEnvironment } from '@bloxwap/hig/contracts';
6
+ import { defaultMessages, resolveMessages } from '@bloxwap/hig/contracts/messages';
7
+ /** Direction of a host-supplied locale (for example expo-localization's `getLocales()[0]`) for `HIGProvider direction`; see #86. */
8
+ export { localeDirection } from '@bloxwap/hig/contracts';
9
+ /** HIG's table for a colour space and platform: `nativeDisplayP3` for `display-p3` on iOS, sRGB everywhere else (including unknown values from untyped JS). */
10
+ export function colorTable(colorSpace, os = Platform.OS) { return colorSpace === 'display-p3' && os === 'ios' ? nativeDisplayP3 : nativeSrgb; }
11
+ const Context = createContext({ ...defaultEnvironment, direction: I18nManager.isRTL ? 'rtl' : 'ltr', colorSpace: 'srgb', messages: {} });
12
+ /** Market-direction roles default to `buy`/`sell`; a host whose convention differs (KRX, A-share) overrides them through `HIGProvider marketColors`. */
13
+ function withMarketRoles(table, up, down) { return { ...table, up: up ?? table.buy, down: down ?? table.sell }; }
14
+ const marketColor = (value) => typeof value === 'string' && value !== '' ? value : undefined;
15
+ // Providers without an accent or market override share one table per colour space, so their colours keep a stable identity.
16
+ const srgbColors = withMarketRoles(nativeSrgb), displayP3Colors = withMarketRoles(nativeDisplayP3);
17
+ const ColorsContext = createContext(srgbColors);
18
+ /** Direction defaults to the OS layout direction (I18nManager) so HIG roots never force LTR inside an RTL app. React Native 0.83 Android does not report a per-app RTL locale through I18nManager (#86): RTL hosts pass `direction={localeDirection(getLocales()[0])}`. Hosts that disallow RTL leave `direction` unset. */
19
+ export function HIGProvider({ children, density = 'comfortable', locale = 'en-US', direction = I18nManager.isRTL ? 'rtl' : 'ltr', reducedMotion, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace, primaryColor, marketColors, messages }) {
20
+ const parent = useContext(Context);
21
+ const inherited = parent.messages;
22
+ const resolved = useMemo(() => resolveMessages(inherited, messages), [inherited, messages]);
23
+ const accent = primaryColor ?? parent.primaryColor;
24
+ const normalized = useMemo(() => accent === undefined ? undefined : resolvePrimaryColor(accent).action, [accent]);
25
+ const space = colorSpace ?? parent.colorSpace;
26
+ const baseColors = colorTable(space);
27
+ const market = marketColors ?? parent.marketColors;
28
+ const marketUp = marketColor(market?.up), marketDown = marketColor(market?.down);
29
+ const inheritedMarket = useMemo(() => marketUp === undefined && marketDown === undefined ? undefined : { up: marketUp, down: marketDown }, [marketUp, marketDown]);
30
+ const colors = useMemo(() => normalized === undefined && marketUp === undefined && marketDown === undefined ? baseColors === nativeDisplayP3 ? displayP3Colors : srgbColors : withMarketRoles(normalized === undefined ? baseColors : { ...baseColors, ...resolvePrimaryColor(normalized, space === 'display-p3' && Platform.OS === 'ios' ? 'display-p3' : 'srgb') }, marketUp, marketDown), [baseColors, space, normalized, marketUp, marketDown]);
31
+ const [osReduced, setOSReduced] = useState(false);
32
+ useEffect(() => { let alive = true; void AccessibilityInfo.isReduceMotionEnabled().then(v => { if (alive)
33
+ setOSReduced(v); }).catch(() => { }); const sub = AccessibilityInfo.addEventListener('reduceMotionChanged', setOSReduced); return () => { alive = false; sub.remove(); }; }, []);
34
+ return _jsx(Context.Provider, { value: { density, locale, direction, reducedMotion: reducedMotion ?? osReduced, onAccepted, feedback, fontFamily, fontFamilies, fontFamiliesByScript: fontFamiliesByScript ?? parent.fontFamiliesByScript, monoFontFamily, maxFontSizeMultiplier, letterSpacingByScript, colorSpace: space, primaryColor: normalized, marketColors: inheritedMarket, messages: resolved }, children: _jsx(ColorsContext.Provider, { value: colors, children: children }) });
35
+ }
36
+ export const useHIG = () => useContext(Context);
37
+ const RaisedContext = createContext(false);
38
+ /** Marks content that sits on a Surface, Dialog or sheet. HIG has no resting strokes, so wells inside step up one fill to stay visible. */
39
+ export function Raised({ children }) { return _jsx(RaisedContext.Provider, { value: true, children: children }); }
40
+ /** Fills for the current elevation: `well` for inputs, tracks and neutral chips; `raised` for what sits on a well (a selected segment). On the page they are `surface` and `nested`; inside a Surface, Dialog or sheet, `nested` and `border`. */
41
+ export function useFills() { const colors = useContext(ColorsContext); return useContext(RaisedContext) ? { well: colors.nested, raised: colors.border } : { well: colors.surface, raised: colors.nested }; }
42
+ /** The nearest HIGProvider's colour table (sRGB by default). Every HIG native component paints through this; hosts may read it for their own views. */
43
+ export function useColors() { return useContext(ColorsContext); }
44
+ /** Approved Bloxwap brand colours in the host's colour space, independent of a product accent. */
45
+ /** The colour space this subtree actually paints in: `display-p3` only when a provider asked for it on iOS, as in `colorTable`; otherwise `srgb`. */
46
+ export function useColorSpace() { return useContext(Context).colorSpace === 'display-p3' && Platform.OS === 'ios' ? 'display-p3' : 'srgb'; }
47
+ export function useBrandColors() { return colorTable(useContext(Context).colorSpace); }
48
+ /** Complete built-in copy for the nearest HIGProvider: host translations over the English defaults. */
49
+ export function useMessages() { const overrides = useContext(Context).messages; return useMemo(() => resolveMessages({ ...defaultMessages }, overrides), [overrides]); }
50
+ export function useControllable(value, initial, onChange, intent = 'selection') {
51
+ const [internal, setInternal] = useState(initial);
52
+ const current = value === undefined ? internal : value;
53
+ const { feedback } = useHIG();
54
+ const id = useId();
55
+ const sequence = useRef(0);
56
+ const pending = useRef(null);
57
+ useEffect(() => { const request = pending.current; if (!request)
58
+ return; pending.current = null; if (Object.is(current, request.value)) {
59
+ try {
60
+ feedback?.emit({ id: `${id}/${++sequence.current}`, source: id, intent, origin: 'native' });
61
+ }
62
+ catch { /* Effects remain optional. */ }
63
+ } });
64
+ return [current, (next) => { if (Object.is(current, next))
65
+ return; pending.current = { value: next }; if (value === undefined)
66
+ setInternal(next); onChange?.(next); }];
67
+ }
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import type { ChoicesProps } from './selection-types.js';
3
+ export declare function RadioGroup({ label, options, value, defaultValue, disabled, onValueChange }: ChoicesProps): React.JSX.Element;
4
+ /** Equal-width choices with one interruptible selection indicator. The track is the dark well and the selected segment the lighter fill; the control is 44dp tall (36 compact). */
5
+ export declare function SegmentedControl({ label, options, value, defaultValue, disabled, onValueChange }: ChoicesProps): React.JSX.Element;
6
+ export interface FilterOption {
7
+ value: string;
8
+ label: string;
9
+ disabled?: boolean; /** Image URL shown in the option's circle until it is selected. */
10
+ icon?: string;
11
+ }
12
+ export interface FilterProps {
13
+ label: string;
14
+ options: readonly FilterOption[];
15
+ value?: string;
16
+ defaultValue?: string;
17
+ disabled?: boolean;
18
+ onValueChange?: (value: string) => void;
19
+ }
20
+ /** A horizontal, scrolling row of single-choice filter chips. The selected chip inverts and its circle shows a check that animates in. */
21
+ export declare function Filter({ label, options, value, defaultValue, disabled, onValueChange }: FilterProps): React.JSX.Element;
@@ -0,0 +1,91 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useLayoutEffect, useRef, useState } from 'react';
3
+ import { Animated, Easing, Image, Platform, Pressable, ScrollView, View } from 'react-native';
4
+ import { tokens } from '@bloxwap/hig/tokens';
5
+ import { useControllable, useColors, useFills, useHIG } from './provider.js';
6
+ import { Text } from './surface.js';
7
+ export function RadioGroup({ label, options, value, defaultValue = '', disabled, onValueChange }) {
8
+ const [current, set] = useControllable(value, defaultValue, onValueChange);
9
+ const { direction, locale } = useHIG();
10
+ const colors = useColors();
11
+ return _jsxs(View, { accessibilityRole: 'radiogroup', accessibilityLabel: label, style: { direction }, children: [_jsx(Text, { children: label }), options.map(o => {
12
+ const blocked = !!disabled || !!o.disabled;
13
+ const activate = () => { if (!blocked)
14
+ set(o.value); };
15
+ return _jsxs(Pressable, { accessible: true, accessibilityRole: 'radio', "aria-checked": current === o.value, "aria-disabled": blocked, accessibilityLabel: o.label, accessibilityHint: o.description, accessibilityLanguage: o.lang, accessibilityState: { checked: current === o.value, disabled: blocked }, accessibilityActions: [{ name: 'activate' }], disabled: blocked, onPress: activate, onAccessibilityAction: event => { if (event.nativeEvent.actionName === 'activate')
16
+ activate(); }, style: { minHeight: 48, paddingVertical: 12, flexDirection: 'row', alignItems: 'center', gap: 12, opacity: blocked ? 0.5 : 1 }, children: [_jsx(Text, { accessible: false, children: current === o.value ? '●' : '○' }), _jsxs(View, { style: { flex: 1 }, children: [_jsx(Text, { accessible: false, accessibilityLanguage: o.lang, children: o.label }), o.description !== undefined && _jsx(Text, { accessible: false, accessibilityLanguage: locale, style: { color: colors.muted, fontSize: 14, lineHeight: 20 }, children: o.description })] })] }, o.value);
17
+ })] });
18
+ }
19
+ /** Segments are 36dp inside a 44dp track; the slop restores a 48dp touch target. */
20
+ const segmentSlop = { top: 6, bottom: 6 };
21
+ /** Equal-width choices with one interruptible selection indicator. The track is the dark well and the selected segment the lighter fill; the control is 44dp tall (36 compact). */
22
+ export function SegmentedControl({ label, options, value, defaultValue = '', disabled, onValueChange }) {
23
+ const [current, set] = useControllable(value, defaultValue, onValueChange);
24
+ const { direction, locale, reducedMotion, density } = useHIG();
25
+ const colors = useColors();
26
+ const fills = useFills();
27
+ const compact = density === 'compact';
28
+ const [width, setWidth] = useState(0);
29
+ const translateX = useRef(new Animated.Value(0)).current;
30
+ const selected = options.findIndex(option => option.value === current), count = options.length;
31
+ const segmentWidth = count > 0 ? Math.max(0, (width - (count - 1) * 4) / count) : 0;
32
+ const target = selected >= 0 ? (direction === 'rtl' ? -1 : 1) * selected * (segmentWidth + 4) : 0;
33
+ // RN Web resolves `start` through its own locale context rather than this View's direction.
34
+ const anchor = Platform.OS === 'web' ? (direction === 'rtl' ? { right: 0 } : { left: 0 }) : { start: 0 };
35
+ const previous = useRef(null);
36
+ useLayoutEffect(() => {
37
+ const old = previous.current;
38
+ previous.current = { selected, width, count, direction };
39
+ // Initial layout, rotation, option-count changes and reduced motion snap into place.
40
+ // A new selection interrupts the running animation at its current position.
41
+ if (reducedMotion || !old || old.selected === selected || old.selected < 0 || selected < 0 || old.width !== width || old.count !== count || old.direction !== direction) {
42
+ translateX.stopAnimation();
43
+ translateX.setValue(target);
44
+ return;
45
+ }
46
+ const animation = Animated.timing(translateX, { toValue: target, duration: tokens.motion.base, easing: Easing.bezier(...tokens.easing.standard), useNativeDriver: Platform.OS !== 'web', isInteraction: false });
47
+ animation.start();
48
+ return () => animation.stop();
49
+ }, [selected, width, count, direction, reducedMotion, target, translateX]);
50
+ return _jsxs(View, { accessibilityRole: 'radiogroup', accessibilityLabel: label, style: { direction, gap: 8 }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: label }), _jsx(View, { style: { padding: 4, borderRadius: 9999, backgroundColor: fills.well }, children: _jsxs(View, { onLayout: event => setWidth(event.nativeEvent.layout.width), style: { flexDirection: 'row', gap: 4 }, children: [selected >= 0 && width > 0 && _jsx(Animated.View, { pointerEvents: 'none', accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', style: { position: 'absolute', ...anchor, top: 0, bottom: 0, width: segmentWidth, borderRadius: 9999, backgroundColor: fills.raised, opacity: disabled || options[selected].disabled ? 0.5 : 1, transform: [{ translateX }] } }), options.map(option => {
51
+ const checked = current === option.value, blocked = !!disabled || !!option.disabled;
52
+ const activate = () => { if (!blocked)
53
+ set(option.value); };
54
+ return _jsxs(Pressable, { accessible: true, accessibilityRole: 'radio', accessibilityLabel: option.label, accessibilityHint: option.description, accessibilityLanguage: option.lang, "aria-checked": checked, "aria-disabled": blocked, accessibilityState: { checked, disabled: blocked }, accessibilityActions: [{ name: 'activate' }], disabled: blocked, onPress: activate, onAccessibilityAction: event => { if (event.nativeEvent.actionName === 'activate')
55
+ activate(); }, hitSlop: segmentSlop, style: { flex: 1, minWidth: 0, minHeight: compact ? 28 : 36, paddingHorizontal: 12, paddingVertical: compact ? 2 : 4, alignItems: 'stretch', justifyContent: 'center', borderRadius: 9999, opacity: blocked ? 0.5 : 1 }, children: [_jsx(Text, { accessible: false, accessibilityLanguage: option.lang, style: { color: checked ? colors.text : colors.muted, fontWeight: '500', textAlign: 'center' }, children: option.label }), option.description !== undefined && _jsx(Text, { accessible: false, accessibilityLanguage: locale, style: { color: colors.muted, fontSize: 14, lineHeight: 20, textAlign: 'center' }, children: option.description })] }, option.value);
56
+ })] }) })] });
57
+ }
58
+ /** Chips are 40dp; the slop restores a 44dp touch target. */
59
+ const filterSlop = { top: 2, bottom: 2 };
60
+ const hiddenMark = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', pointerEvents: 'none' };
61
+ /** One chip. Its circle holds the option's icon or an empty ring; when the chip is selected the circle fills and a check settles in, and deselecting reverses it. */
62
+ function FilterChip({ option, checked, blocked, reducedMotion, onSelect }) {
63
+ const colors = useColors();
64
+ const fills = useFills();
65
+ const progress = useRef(new Animated.Value(checked ? 1 : 0)).current;
66
+ const first = useRef(true);
67
+ useEffect(() => {
68
+ const target = checked ? 1 : 0;
69
+ // The first render and reduced motion show the final state at once.
70
+ if (first.current || reducedMotion) {
71
+ first.current = false;
72
+ progress.stopAnimation();
73
+ progress.setValue(target);
74
+ return;
75
+ }
76
+ const animation = Animated.timing(progress, { toValue: target, duration: 220, easing: Easing.bezier(...tokens.easing.standard), useNativeDriver: Platform.OS !== 'web', isInteraction: false });
77
+ animation.start();
78
+ return () => animation.stop();
79
+ }, [checked, reducedMotion, progress]);
80
+ const ink = checked ? colors.background : colors.text;
81
+ const activate = () => { if (!blocked)
82
+ onSelect(); };
83
+ return _jsxs(Pressable, { accessible: true, accessibilityRole: 'radio', accessibilityLabel: option.label, "aria-checked": checked, "aria-disabled": blocked, accessibilityState: { checked, disabled: blocked }, accessibilityActions: [{ name: 'activate' }], disabled: blocked, onPress: activate, onAccessibilityAction: event => { if (event.nativeEvent.actionName === 'activate')
84
+ activate(); }, hitSlop: filterSlop, style: state => ({ flexDirection: 'row', alignItems: 'center', gap: 8, minHeight: 40, paddingVertical: 6, paddingStart: 8, paddingEnd: 16, borderRadius: 9999, backgroundColor: checked ? colors.text : state.pressed ? fills.raised : fills.well, opacity: blocked ? 0.5 : 1 }), children: [_jsxs(View, { ...hiddenMark, style: { width: 24, height: 24, borderRadius: 12, overflow: 'hidden', alignItems: 'center', justifyContent: 'center' }, children: [option.icon ? _jsx(Image, { source: { uri: option.icon }, accessible: false, style: { position: 'absolute', width: 24, height: 24, borderRadius: 12 } }) : _jsx(View, { style: { position: 'absolute', width: 24, height: 24, borderRadius: 12, borderWidth: 2, borderColor: ink } }), _jsx(Animated.View, { style: { position: 'absolute', width: 24, height: 24, borderRadius: 12, backgroundColor: colors.background, opacity: progress } }), _jsx(Animated.View, { style: { opacity: progress, transform: [{ scale: progress.interpolate({ inputRange: [0, 1], outputRange: [0.4, 1] }) }] }, children: _jsx(View, { style: { width: 11, height: 6, borderLeftWidth: 2, borderBottomWidth: 2, borderColor: colors.text, transform: [{ translateY: -1.5 }, { rotate: '-45deg' }] } }) })] }), _jsx(Text, { accessible: false, style: { fontSize: 14, lineHeight: 21, fontWeight: '600', color: ink }, children: option.label })] });
85
+ }
86
+ /** A horizontal, scrolling row of single-choice filter chips. The selected chip inverts and its circle shows a check that animates in. */
87
+ export function Filter({ label, options, value, defaultValue = '', disabled, onValueChange }) {
88
+ const [current, set] = useControllable(value, defaultValue, onValueChange);
89
+ const { direction, reducedMotion } = useHIG();
90
+ return _jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, keyboardShouldPersistTaps: 'handled', accessibilityRole: 'radiogroup', accessibilityLabel: label, style: { flexGrow: 0, direction }, contentContainerStyle: { direction, gap: 8 }, children: options.map(option => _jsx(FilterChip, { option: option, checked: current === option.value, blocked: !!disabled || !!option.disabled, reducedMotion: !!reducedMotion, onSelect: () => set(option.value) }, option.value)) });
91
+ }
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ export declare function MarketRow({ symbol, name, price, change, onSelect }: {
3
+ symbol: string;
4
+ name: string;
5
+ price: number | null;
6
+ change: number | null;
7
+ onSelect: () => void;
8
+ }): React.JSX.Element;
9
+ export declare function BalanceCard({ label, balance, stale }: {
10
+ label: string;
11
+ balance: number | null;
12
+ stale?: boolean;
13
+ }): React.JSX.Element;
14
+ export declare function TradeEntry({ asset, amount, onAmountChange, onConfirm, busy, error, available }: {
15
+ asset: string;
16
+ amount: string;
17
+ onAmountChange: (v: string) => void;
18
+ onConfirm: () => void;
19
+ busy?: boolean;
20
+ error?: string;
21
+ available: string;
22
+ }): React.JSX.Element;
23
+ /** A copy outcome shows as a transient toast capsule (about 4s, dismissible) and is announced the way Toast announces any notice. */
24
+ export declare function InstallCommand({ command, onCopy }: {
25
+ command: string;
26
+ onCopy: () => Promise<void> | void;
27
+ }): React.JSX.Element;
28
+ export declare function CodeWindow({ language, children }: React.PropsWithChildren<{
29
+ language: string;
30
+ }>): React.JSX.Element;
31
+ export declare function MarketingHero({ title, description, href, cta }: {
32
+ title: string;
33
+ description: string;
34
+ href: string;
35
+ cta: string;
36
+ }): React.JSX.Element;
37
+ export declare function ActivityList({ items }: {
38
+ items: readonly {
39
+ id: string;
40
+ label: string;
41
+ status: string;
42
+ }[];
43
+ }): React.JSX.Element;
44
+ export { FromPicker, ToPicker, type FromPickerProps, type ToPickerProps, type PickerListProps } from './pickers.js';
45
+ export { SwapPanel, swapAction, type SwapPanelProps, type SwapToken, type SwapChain, type SwapAction, type SwapDenomination, type SwapWallet, type SwapFee, type SwapReceive, type SwapDestination, type SwapDetail, type SwapView } from './swap-panel.js';
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { Platform } from 'react-native';
4
+ import * as en from '@bloxwap/hig/contracts/messages';
5
+ import { useColors, useHIG } from './provider.js';
6
+ import { Button, Link } from './button.js';
7
+ import { Surface, Stack, Heading, Text } from './surface.js';
8
+ import { Field, AmountInput } from './field.js';
9
+ import { Dialog } from './overlay.js';
10
+ import { Row, Usd, Percent, List } from './data.js';
11
+ import { Toast, useTransientNotice } from './status.js';
12
+ export function MarketRow({ symbol, name, price, change, onSelect }) { return _jsxs(Row, { children: [_jsxs(Button, { intent: 'ghost', onPress: onSelect, children: [name, " (", symbol, ")"] }), _jsx(Usd, { value: price }), _jsx(Percent, { value: change })] }); }
13
+ export function BalanceCard({ label, balance, stale }) { const colors = useColors(); return _jsxs(Surface, { style: { gap: 8 }, children: [_jsx(Text, { style: { color: colors.muted, fontSize: 14, lineHeight: 21 }, children: label }), _jsx(Usd, { value: balance, stale: stale, style: { fontSize: 24, lineHeight: 30, fontWeight: '600' } })] }); }
14
+ /** The call to action that closes a form sits a double step, 16dp, below it (the Stack gap is 12). */
15
+ const formAction = { marginTop: 4 };
16
+ /** In a dialog the confirm action is 16dp below the content and 8dp above the dialog's own closing button, which adds 4dp itself. */
17
+ const dialogAction = { marginTop: 4, marginBottom: -8 };
18
+ export function TradeEntry({ asset, amount, onAmountChange, onConfirm, busy, error, available }) { const { messages } = useHIG(); const [review, setReview] = useState(false); return _jsx(Surface, { children: _jsxs(Stack, { children: [_jsx(Heading, { children: (messages.reviewAssetOrder ?? en.reviewAssetOrder)(asset) }), _jsx(Field, { label: (messages.amountInAsset ?? en.amountInAsset)(asset), description: (messages.availableAmount ?? en.availableAmount)(available), error: error, children: _jsx(AmountInput, { value: amount, onChangeText: onAmountChange, editable: !busy }) }), _jsx(Button, { fullWidth: true, style: formAction, disabled: !amount || !!error, busy: busy, onPress: () => setReview(true), children: messages.reviewOrder ?? en.reviewOrder }), _jsxs(Dialog, { open: review, onOpenChange: setReview, title: messages.confirmOrder ?? en.confirmOrder, description: (messages.confirmOrderDescription ?? en.confirmOrderDescription)(amount, asset), children: [_jsx(Button, { busy: busy, disabled: !!error, style: dialogAction, onPress: onConfirm, children: messages.confirmOrder ?? en.confirmOrder }), error && _jsx(Text, { accessibilityLiveRegion: 'polite', children: error })] })] }) }); }
19
+ /** Code and commands stay monospace and left-to-right inside RTL roots. */
20
+ function useCodeStyle() { const env = useHIG(); return { fontFamily: env.monoFontFamily ?? Platform.select({ ios: 'Menlo', default: 'monospace' }), writingDirection: 'ltr', textAlign: 'left' }; }
21
+ /** A copy outcome shows as a transient toast capsule (about 4s, dismissible) and is announced the way Toast announces any notice. */
22
+ export function InstallCommand({ command, onCopy }) {
23
+ const { messages } = useHIG();
24
+ const { notice, show, dismiss } = useTransientNotice();
25
+ const code = useCodeStyle();
26
+ return _jsxs(Surface, { style: { gap: 12 }, children: [_jsx(Text, { selectable: true, style: code, children: command }), _jsx(Button, { intent: 'secondary', onPress: () => { Promise.resolve().then(onCopy).then(() => show(messages.copied ?? en.copied, 'success')).catch(() => show(messages.copyFailed ?? en.copyFailed, 'error')); }, children: messages.copyInstallCommand ?? en.copyInstallCommand }), notice && _jsx(Toast, { notices: [notice], onDismiss: dismiss })] });
27
+ }
28
+ export function CodeWindow({ language, children }) { const code = useCodeStyle(); return _jsxs(Surface, { children: [_jsx(Text, { children: language }), _jsx(Text, { selectable: true, style: code, children: children })] }); }
29
+ export function MarketingHero({ title, description, href, cta }) { return _jsxs(Stack, { children: [_jsx(Heading, { children: title }), _jsx(Text, { children: description }), _jsx(Link, { href: href, children: cta })] }); }
30
+ export function ActivityList({ items }) { const { messages } = useHIG(); return _jsx(List, { items: items, keyFor: i => i.id, render: i => _jsxs(Row, { children: [_jsx(Text, { children: i.label }), _jsx(Text, { children: i.status })] }), empty: messages.noActivity ?? en.noActivity }); }
31
+ export { FromPicker, ToPicker } from './pickers.js';
32
+ export { SwapPanel, swapAction } from './swap-panel.js';
@@ -0,0 +1,6 @@
1
+ import type { HIGColors } from './provider.js';
2
+ /** Semantic token roles a host may choose for a control or status accent. Raw colours are not accepted, so product palettes are never copied into HIG consumers. */
3
+ export declare const accentRoles: readonly ['action', 'positive', 'negative', 'warning', 'info', 'buy', 'sell'];
4
+ export type AccentRole = typeof accentRoles[number];
5
+ /** Resolves a role to its colour in the provider's table (`useColors()`); anything outside the role list (for example a hex string from untyped JS) falls back to the component default. */
6
+ export declare function roleColor(role: unknown, fallback: AccentRole, colors: HIGColors): string;
@@ -0,0 +1,4 @@
1
+ /** Semantic token roles a host may choose for a control or status accent. Raw colours are not accepted, so product palettes are never copied into HIG consumers. */
2
+ export const accentRoles = ['action', 'positive', 'negative', 'warning', 'info', 'buy', 'sell'];
3
+ /** Resolves a role to its colour in the provider's table (`useColors()`); anything outside the role list (for example a hex string from untyped JS) falls back to the component default. */
4
+ export function roleColor(role, fallback, colors) { return colors[accentRoles.includes(role) ? role : fallback]; }
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { ChoicesProps } from './selection-types.js';
3
+ export declare function Select(props: ChoicesProps): React.JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useRef } from 'react';
3
+ import { View } from 'react-native';
4
+ import * as en from '@bloxwap/hig/contracts/messages';
5
+ import { useControllable, useHIG } from './provider.js';
6
+ import { Button } from './button.js';
7
+ import { Dialog } from './overlay.js';
8
+ import { RadioGroup } from './radio-group.js';
9
+ export function Select(props) { const { messages } = useHIG(); const [open, setOpen] = useState(false); const trigger = useRef(null); const [current, set] = useControllable(props.value, props.defaultValue ?? '', props.onValueChange); return _jsxs(View, { children: [_jsxs(Button, { ref: trigger, disabled: props.disabled, intent: 'secondary', onPress: () => setOpen(true), children: [props.label, ": ", props.options.find(o => o.value === current)?.label ?? messages.choose ?? en.choose] }), _jsx(Dialog, { title: props.label, description: messages.chooseOne ?? en.chooseOne, open: open, onOpenChange: setOpen, returnFocusRef: trigger, children: _jsx(RadioGroup, { ...props, value: current, onValueChange: v => { set(v); setOpen(false); } }) })] }); }