@bloxwap/hig 0.2.0 → 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 (119) hide show
  1. package/README.md +1 -1
  2. package/chart/README.md +3 -3
  3. package/contracts/README.md +1 -1
  4. package/contracts/dist/messages.d.ts +138 -0
  5. package/contracts/dist/messages.js +48 -2
  6. package/css.d.ts +2 -0
  7. package/feedback/README.md +1 -1
  8. package/feedback/assets/error.wav +0 -0
  9. package/feedback/assets/manifest.json +29 -19
  10. package/feedback/assets/tick.wav +0 -0
  11. package/feedback/assets/toggle.wav +0 -0
  12. package/feedback/dist/contract.d.ts +1 -57
  13. package/feedback/dist/contract.js +2 -1
  14. package/feedback/dist/native.d.ts +2 -1
  15. package/feedback/dist/presets.d.ts +57 -0
  16. package/feedback/dist/presets.js +1 -0
  17. package/native/README.md +6 -1
  18. package/native/dist/animated-number.js +11 -7
  19. package/native/dist/brand.d.ts +1 -1
  20. package/native/dist/brand.js +4 -3
  21. package/native/dist/button.d.ts +3 -2
  22. package/native/dist/button.js +8 -6
  23. package/native/dist/data.d.ts +18 -1
  24. package/native/dist/data.js +22 -2
  25. package/native/dist/field.d.ts +1 -0
  26. package/native/dist/field.js +18 -5
  27. package/native/dist/gesture-sheet.js +5 -3
  28. package/native/dist/icons.d.ts +21 -0
  29. package/native/dist/icons.js +20 -0
  30. package/native/dist/navigation.d.ts +1 -0
  31. package/native/dist/navigation.js +49 -7
  32. package/native/dist/overlay.js +3 -3
  33. package/native/dist/pickers.d.ts +54 -0
  34. package/native/dist/pickers.js +60 -0
  35. package/native/dist/provider.d.ts +25 -6
  36. package/native/dist/provider.js +19 -4
  37. package/native/dist/radio-group.d.ts +17 -1
  38. package/native/dist/radio-group.js +45 -7
  39. package/native/dist/recipes.d.ts +3 -0
  40. package/native/dist/recipes.js +15 -2
  41. package/native/dist/selection.d.ts +1 -0
  42. package/native/dist/selection.js +1 -0
  43. package/native/dist/slider.js +3 -2
  44. package/native/dist/status.d.ts +16 -5
  45. package/native/dist/status.js +55 -15
  46. package/native/dist/surface.d.ts +2 -1
  47. package/native/dist/surface.js +4 -3
  48. package/native/dist/swap-panel.d.ts +125 -0
  49. package/native/dist/swap-panel.js +177 -0
  50. package/native/dist/swap-parts.d.ts +86 -0
  51. package/native/dist/swap-parts.js +66 -0
  52. package/native/dist/swap-shared.d.ts +65 -0
  53. package/native/dist/swap-shared.js +76 -0
  54. package/native/dist/swap-sheet.d.ts +14 -0
  55. package/native/dist/swap-sheet.js +26 -0
  56. package/native/dist/swap-views.d.ts +41 -0
  57. package/native/dist/swap-views.js +37 -0
  58. package/native/dist/switch.d.ts +1 -1
  59. package/native/dist/switch.js +20 -13
  60. package/native/dist/wallet-address.d.ts +37 -0
  61. package/native/dist/wallet-address.js +50 -0
  62. package/native-fonts/README.md +1 -1
  63. package/native-fonts/dist/index.d.ts +1 -1
  64. package/native-fonts/dist/index.js +1 -1
  65. package/native-fonts/fonts/manifest.json +1 -1
  66. package/og-fonts/README.md +2 -2
  67. package/og-fonts/dist/index.d.ts +1 -1
  68. package/og-fonts/dist/index.js +1 -1
  69. package/og-fonts/fonts/manifest.json +1 -1
  70. package/package.json +181 -63
  71. package/react/README.md +22 -1
  72. package/react/dist/animated-number.js +2 -1
  73. package/react/dist/brand.d.ts +1 -1
  74. package/react/dist/brand.js +3 -2
  75. package/react/dist/button.d.ts +2 -2
  76. package/react/dist/button.js +1 -1
  77. package/react/dist/data.d.ts +15 -0
  78. package/react/dist/data.js +13 -0
  79. package/react/dist/field.d.ts +1 -0
  80. package/react/dist/field.js +2 -1
  81. package/react/dist/navigation.js +1 -1
  82. package/react/dist/notify.d.ts +14 -0
  83. package/react/dist/notify.js +6 -0
  84. package/react/dist/recipes/install-command.d.ts +1 -0
  85. package/react/dist/recipes/install-command.js +8 -1
  86. package/react/dist/recipes/pickers.d.ts +57 -0
  87. package/react/dist/recipes/pickers.js +78 -0
  88. package/react/dist/recipes/swap/amount-card.d.ts +40 -0
  89. package/react/dist/recipes/swap/amount-card.js +7 -0
  90. package/react/dist/recipes/swap/picker.d.ts +26 -0
  91. package/react/dist/recipes/swap/picker.js +20 -0
  92. package/react/dist/recipes/swap/settings.d.ts +24 -0
  93. package/react/dist/recipes/swap/settings.js +25 -0
  94. package/react/dist/recipes/swap/shared.d.ts +98 -0
  95. package/react/dist/recipes/swap/shared.js +106 -0
  96. package/react/dist/recipes/swap-panel.d.ts +127 -0
  97. package/react/dist/recipes/swap-panel.js +170 -0
  98. package/react/dist/recipes/swap-sheet.d.ts +16 -0
  99. package/react/dist/recipes/swap-sheet.js +22 -0
  100. package/react/dist/recipes/trade-entry.js +1 -1
  101. package/react/dist/recipes.d.ts +3 -1
  102. package/react/dist/recipes.js +3 -1
  103. package/react/dist/select.js +2 -0
  104. package/react/dist/selection.d.ts +13 -0
  105. package/react/dist/selection.js +7 -0
  106. package/react/dist/status.d.ts +15 -5
  107. package/react/dist/status.js +8 -4
  108. package/react/dist/styles.css +406 -92
  109. package/react/dist/toast.d.ts +17 -0
  110. package/react/dist/toast.js +21 -0
  111. package/react/dist/wallet-address.d.ts +23 -0
  112. package/react/dist/wallet-address.js +24 -0
  113. package/tokens/README.md +9 -1
  114. package/tokens/dist/brand.d.ts +19 -0
  115. package/tokens/dist/brand.js +24 -0
  116. package/tokens/dist/index.d.ts +9 -1
  117. package/tokens/dist/index.js +8 -1
  118. package/tokens/dist/manifest.json +4 -1
  119. package/tokens/dist/tokens.css +1 -0
@@ -0,0 +1,76 @@
1
+ /** Where Back leads: slippage and fees return to settings, everything else to the main form. */
2
+ export const swapParentView = (view) => view === 'slippage' || view === 'fees' ? 'settings' : 'main';
3
+ export const slippagePresets = [0.001, 0.005, 0.01];
4
+ export function swapAction(from, to) {
5
+ if (!from || !to || from.symbol === to.symbol)
6
+ return 'send';
7
+ return from.chainId === to.chainId ? 'swap' : 'bridge';
8
+ }
9
+ /** A clean numeric string: no trailing zeros, at most `digits` decimals. */
10
+ export const trimNumber = (value, digits = 8) => String(Number((Number.isFinite(value) ? value : 0).toFixed(digits)));
11
+ /** Keeps digits and one decimal point, and strips leading zeros; never returns an empty string. */
12
+ export function sanitizeAmount(raw) {
13
+ let value = raw.replace(/[^0-9.]/g, '');
14
+ const dot = value.indexOf('.');
15
+ if (dot !== -1)
16
+ value = value.slice(0, dot + 1) + value.slice(dot + 1).replace(/\./g, '');
17
+ value = value.replace(/^0+(\d)/, '$1');
18
+ return value === '' || value === '.' ? '0' : value;
19
+ }
20
+ /** Token units shown in the active denomination. Dollars floor to the cent so Max never resolves to more than the balance. */
21
+ export function unitsToEntry(units, mode, price) {
22
+ if (mode === 'token')
23
+ return trimNumber(units);
24
+ return price > 0 ? String(Math.floor(units * price * 100) / 100) : '0';
25
+ }
26
+ /** Applies one keypad key (`0`–`9`, `.`, `back`) to an amount string. Dollars stop at two decimals. */
27
+ export function applyAmountKey(current, key, mode) {
28
+ if (key === 'back')
29
+ return current.length <= 1 ? '0' : current.slice(0, -1);
30
+ if (key === '.')
31
+ return current.includes('.') ? current : `${current}.`;
32
+ if (!/^[0-9]$/.test(key))
33
+ return current;
34
+ const next = sanitizeAmount(current === '0' ? key : current + key);
35
+ const dot = next.indexOf('.');
36
+ return mode === 'usd' && dot !== -1 && next.length - dot - 1 > 2 ? current : next;
37
+ }
38
+ /** Case-insensitive substring or in-order subsequence match. */
39
+ export function fuzzyMatch(query, text) {
40
+ const needle = query.toLowerCase().replace(/\s+/g, ''), haystack = text.toLowerCase();
41
+ if (haystack.includes(needle))
42
+ return true;
43
+ let matched = 0;
44
+ for (let index = 0; index < haystack.length && matched < needle.length; index++)
45
+ if (haystack[index] === needle[matched])
46
+ matched++;
47
+ return matched === needle.length;
48
+ }
49
+ /** A slippage fraction as a percent string: 0.005 is `0.5%`. */
50
+ export const formatPercent = (fraction) => `${Number((fraction * 100).toFixed(4))}%`;
51
+ /** A small trial amount: 1% of holdings, capped at about one dollar's worth. */
52
+ export function testAmount(token) {
53
+ const balance = token.balance ?? 0, price = token.price ?? 0;
54
+ if (!(balance > 0))
55
+ return 0;
56
+ return Number(Math.min(balance * 0.01, price > 0 ? 1 / price : balance * 0.01).toFixed(8));
57
+ }
58
+ export const shortAddress = (address) => address.length <= 12 ? address : `${address.slice(0, 6)}…${address.slice(-4)}`;
59
+ /** A stable flat colour for a wallet address, so the same wallet always looks the same. */
60
+ export function addressColor(address) {
61
+ let hash = 0;
62
+ for (const character of address)
63
+ hash = (hash * 31 + character.charCodeAt(0)) >>> 0;
64
+ return `hsl(${hash % 360}, 75%, 55%)`;
65
+ }
66
+ /** Picker rows: hot tokens lead the unfiltered list; any search or chain filter gives one flat list. */
67
+ export function pickerRows(tokens, query, chainId, hotTokenIds) {
68
+ const text = query.trim();
69
+ const filtered = tokens.filter(token => (chainId === null || token.chainId === chainId) && (text === '' || fuzzyMatch(text, `${token.name} ${token.symbol} ${token.chain} ${token.keywords ?? ''}`)));
70
+ if (text !== '' || chainId !== null || !hotTokenIds?.length)
71
+ return { rows: filtered, hotCount: 0 };
72
+ const hot = hotTokenIds.map(id => filtered.find(token => token.id === id)).filter((token) => !!token);
73
+ if (!hot.length || hot.length === filtered.length)
74
+ return { rows: filtered, hotCount: 0 };
75
+ return { rows: [...hot, ...filtered.filter(token => !hot.includes(token))], hotCount: hot.length };
76
+ }
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { type SwapPanelProps } from './swap-panel.js';
3
+ export interface SwapSheetProps extends SwapPanelProps {
4
+ open: boolean;
5
+ onOpenChange: (open: boolean) => void;
6
+ /** Accessible name of the sheet. */
7
+ title: string;
8
+ }
9
+ /**
10
+ * SwapPanel presented in the gesture sheet. Pickers and settings push inside the same sheet, which resizes to the view
11
+ * on show. A back press or a dismiss gesture pops a pushed view first and closes the sheet only from the main form;
12
+ * closing always returns to the main form. Needs the optional gesture-sheet backend, which `recipes` does not load.
13
+ */
14
+ export declare function SwapSheet({ open, onOpenChange, title, view: viewProp, onViewChange, style, ...panel }: SwapSheetProps): React.JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useState } from 'react';
3
+ import { BottomSheetFlatList } from '@gorhom/bottom-sheet';
4
+ import { GestureSheet } from './gesture-sheet.js';
5
+ import { SwapHostContext, SwapPanel, swapParentView } from './swap-panel.js';
6
+ /**
7
+ * SwapPanel presented in the gesture sheet. Pickers and settings push inside the same sheet, which resizes to the view
8
+ * on show. A back press or a dismiss gesture pops a pushed view first and closes the sheet only from the main form;
9
+ * closing always returns to the main form. Needs the optional gesture-sheet backend, which `recipes` does not load.
10
+ */
11
+ export function SwapSheet({ open, onOpenChange, title, view: viewProp, onViewChange, style, ...panel }) {
12
+ const [ownView, keepView] = useState('main');
13
+ const view = viewProp ?? ownView;
14
+ const show = (next) => { if (next === view)
15
+ return; if (viewProp === undefined)
16
+ keepView(next); onViewChange?.(next); };
17
+ useEffect(() => { if (!open)
18
+ show('main'); }, [open]);
19
+ // The backend's list hands drags at its scroll edge to the sheet; the sheet sizes to its content, so the panel keeps its height still.
20
+ const host = useMemo(() => ({ listComponent: BottomSheetFlatList, animateHeight: false }), []);
21
+ const leave = () => { if (view === 'main')
22
+ return false; show(swapParentView(view)); return true; };
23
+ return _jsx(GestureSheet, { open: open, onOpenChange: next => { if (!next && leave())
24
+ return; onOpenChange(next); }, title: title, contentMode: 'custom', enableDynamicSizing: true, keyboardBehavior: 'interactive', onHardwareBackPress: () => { if (!leave())
25
+ onOpenChange(false); return true; }, children: _jsx(SwapHostContext.Provider, { value: host, children: _jsx(SwapPanel, { ...panel, view: view, onViewChange: show, style: [{ paddingHorizontal: 12, paddingBottom: 16 }, style] }) }) });
26
+ }
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { type SwapChain, type SwapDenomination, type SwapFee, type SwapToken, type SwapWallet } from './swap-shared.js';
3
+ export interface SwapPickerProps {
4
+ side: 'from' | 'to';
5
+ onBack: () => void;
6
+ tokens: readonly SwapToken[];
7
+ chains: readonly SwapChain[];
8
+ hotTokenIds?: readonly string[];
9
+ selected: SwapToken | null;
10
+ onSelect: (token: SwapToken) => void;
11
+ loading?: boolean;
12
+ wallet?: SwapWallet;
13
+ onConnect?: () => void;
14
+ onDisconnect?: () => void;
15
+ /** From side, before a wallet is connected: the Generate address switch, which puts the panel in its receive view. */
16
+ receiving?: boolean;
17
+ onReceivingChange?: (receiving: boolean) => void;
18
+ /** To side: where the assets are sent. Omit `onRecipientChange` to hide the field. */
19
+ recipient?: string;
20
+ onRecipientChange?: (address: string) => void;
21
+ onScanRecipient?: () => void;
22
+ }
23
+ /** The panel's pushed picker view: the sub-view header over the From or To picker recipe. Choosing a token pops back; the Generate address switch does not. */
24
+ export declare function SwapPicker({ side, onBack, selected, onSelect, wallet, onConnect, onDisconnect, receiving, onReceivingChange, recipient, onRecipientChange, onScanRecipient, ...list }: SwapPickerProps): React.JSX.Element;
25
+ export type SwapSettingsView = 'settings' | 'slippage' | 'fees';
26
+ export interface SwapSettingsProps {
27
+ view: SwapSettingsView;
28
+ onViewChange: (view: SwapSettingsView) => void;
29
+ onBack: () => void;
30
+ denomination: SwapDenomination; /** Omit to hide the denomination setting. */
31
+ onDenominationChange?: (denomination: SwapDenomination) => void;
32
+ slippage: number;
33
+ onSlippageChange?: (slippage: number) => void;
34
+ fee?: number | null;
35
+ fees?: readonly SwapFee[];
36
+ quoteLoading?: boolean;
37
+ /** Host rows shown under the built-in settings, such as language or theme. */
38
+ children?: React.ReactNode;
39
+ }
40
+ /** The settings views. Slippage and the fee breakdown push from the settings list, and Back returns to it. */
41
+ export declare function SwapSettings({ view, onViewChange, onBack, denomination, onDenominationChange, slippage, onSlippageChange, fee, fees, quoteLoading, children }: SwapSettingsProps): React.JSX.Element;
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { Pressable, View } 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 { Field, Input } from './field.js';
8
+ import { SegmentedControl } from './radio-group.js';
9
+ import { ChevronIcon } from './icons.js';
10
+ import { SwapSubview } from './swap-parts.js';
11
+ import { FromPicker, ToPicker } from './pickers.js';
12
+ import { formatPercent, shortAddress, slippagePresets } from './swap-shared.js';
13
+ /** The panel's pushed picker view: the sub-view header over the From or To picker recipe. Choosing a token pops back; the Generate address switch does not. */
14
+ export function SwapPicker({ side, onBack, selected, onSelect, wallet, onConnect, onDisconnect, receiving, onReceivingChange, recipient, onRecipientChange, onScanRecipient, ...list }) {
15
+ const t = useMessages();
16
+ const choose = (token) => { onSelect(token); onBack(); };
17
+ return _jsx(SwapSubview, { title: side === 'from' ? t.swapFrom : t.swapTo, onBack: onBack, testID: `swap-picker-${side}`, children: side === 'from'
18
+ ? _jsx(FromPicker, { ...list, selected: selected, onSelect: choose, wallet: wallet ?? { connected: false }, onConnect: onConnect, onDisconnect: onDisconnect, generateAddress: !!receiving, onGenerateAddressChange: onReceivingChange })
19
+ : _jsx(ToPicker, { ...list, selected: selected, onSelect: choose, address: recipient, onAddressChange: onRecipientChange, addressPlaceholder: wallet?.address ? shortAddress(wallet.address) : undefined, onScan: onScanRecipient }) });
20
+ }
21
+ /** The settings views. Slippage and the fee breakdown push from the settings list, and Back returns to it. */
22
+ export function SwapSettings({ view, onViewChange, onBack, denomination, onDenominationChange, slippage, onSlippageChange, fee, fees, quoteLoading, children }) {
23
+ const { locale, direction } = useHIG();
24
+ const colors = useColors();
25
+ const fills = useFills();
26
+ const t = useMessages();
27
+ const usd = (value) => formatNumber(value, locale, { style: 'currency', currency: 'USD' });
28
+ const [custom, setCustom] = useState(null);
29
+ const title = view === 'slippage' ? t.swapSlippageTitle : view === 'fees' ? t.swapFees : t.swapSettings;
30
+ const feeText = quoteLoading ? '…' : fee != null ? usd(fee) : '—';
31
+ const preset = slippagePresets.find(value => Math.abs(value - slippage) < 1e-9);
32
+ const row = (name, value, target) => _jsxs(Pressable, { accessibilityRole: 'button', accessibilityLabel: `${name}: ${value}`, testID: `swap-setting-${target}`, onPress: () => onViewChange(target), style: ({ pressed }) => ({ direction, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, minHeight: 48, paddingVertical: 8, paddingHorizontal: 16, borderRadius: 9999, backgroundColor: pressed ? fills.raised : fills.well }), children: [_jsx(Text, { style: { fontWeight: '600' }, children: name }), _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 6 }, children: [_jsx(Text, { style: { color: colors.muted }, children: value }), _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] })] });
33
+ const feeRow = (name, value, total) => _jsxs(View, { style: { flexDirection: 'row', justifyContent: 'space-between', gap: 12, paddingTop: total ? 12 : 0 }, children: [_jsx(Text, { style: { color: total ? colors.text : colors.muted, fontWeight: total ? '600' : '400' }, children: name }), _jsx(Text, { style: { fontWeight: total ? '600' : '400' }, children: value })] }, name);
34
+ const slippageRow = onSlippageChange ? row(t.swapSlippageTitle, formatPercent(slippage), 'slippage') : null, feesRow = row(t.swapFees, feeText, 'fees');
35
+ return _jsxs(SwapSubview, { title: title, onBack: onBack, testID: `swap-view-${view}`, children: [view === 'settings' ? _jsxs(View, { style: { gap: 12 }, children: [onDenominationChange && _jsx(SegmentedControl, { label: t.swapDenomination, options: [{ value: 'usd', label: t.swapDollars }, { value: 'token', label: t.swapUnits }], value: denomination, onValueChange: value => onDenominationChange(value) }), slippageRow, feesRow, children] }) : null, view === 'slippage' && onSlippageChange ? _jsxs(View, { style: { gap: 12 }, children: [_jsx(SegmentedControl, { label: t.swapSlippageTitle, options: slippagePresets.map(value => ({ value: String(value), label: formatPercent(value) })), value: preset === undefined ? '' : String(preset), onValueChange: value => { setCustom(null); onSlippageChange(Number(value)); } }), _jsx(Field, { label: t.swapSlippageCustom, children: _jsx(Input, { keyboardType: 'decimal-pad', value: custom ?? String(Number((slippage * 100).toFixed(4))), onChangeText: entered => { const raw = entered.replace(/[^0-9.]/g, ''); setCustom(raw); const percent = Number.parseFloat(raw); if (Number.isFinite(percent) && percent >= 0 && percent <= 50)
36
+ onSlippageChange(percent / 100); } }) })] }) : null, view === 'fees' ? _jsxs(View, { style: { gap: 12 }, children: [fees?.map(item => feeRow(item.label, usd(item.usd))), feeRow(t.swapFeeTotal, feeText, true)] }) : null] });
37
+ }
@@ -5,6 +5,6 @@ export type { AccentRole } from './roles.js';
5
5
  export interface SwitchProps extends CheckedProps {
6
6
  tone?: AccentRole;
7
7
  }
8
- /** On iOS/Android the whole labeled row is one 48dp switch target; the platform track is a hidden visual indicator. */
8
+ /** The off track is the dark `border` grey, so it reads as off on the page and on a card. On iOS/Android the whole labeled row is one 48dp switch target; the platform track is a hidden visual indicator. */
9
9
  export declare function Switch({ label, checked, defaultChecked, disabled, tone, onCheckedChange }: SwitchProps): React.JSX.Element;
10
10
  export { SwitchRow, type SwitchRowProps } from './switch-row.js';
@@ -1,23 +1,30 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Platform, Pressable, Switch as RNSwitch, View } from 'react-native';
3
3
  import { nativeMetrics as tokens } from '@bloxwap/hig/tokens';
4
- import { useColors, useControllable, useHIG } from './provider.js';
5
- import { Text, Inline } from './surface.js';
4
+ import { Text } from './surface.js';
5
+ import { useColors, useControllable, useFills, useHIG } from './provider.js';
6
6
  import { roleColor } from './roles.js';
7
- /** On iOS/Android the whole labeled row is one 48dp switch target; the platform track is a hidden visual indicator. */
7
+ /** react-native-web passes CSS transitions through style. */
8
+ const webEase = { transitionProperty: 'transform, background-color', transitionDuration: '150ms' };
9
+ /** The off track is the dark `border` grey, so it reads as off on the page and on a card. On iOS/Android the whole labeled row is one 48dp switch target; the platform track is a hidden visual indicator. */
8
10
  export function Switch({ label, checked, defaultChecked = false, disabled, tone, onCheckedChange }) {
9
11
  const env = useHIG();
10
12
  const colors = useColors();
11
- const track = { true: roleColor(tone, 'action', colors), false: colors.nested };
12
- // Android otherwise paints the thumb with the app theme accent (Material teal on the emulator), a colour outside the token roles; iOS keeps its native white thumb.
13
- const thumb = Platform.OS === 'android' ? colors.text : undefined;
13
+ const fills = useFills();
14
+ const track = { true: roleColor(tone, 'action', colors), false: fills.raised };
14
15
  const [current, set] = useControllable(checked, defaultChecked, onCheckedChange);
15
- // react-native-web renders the track as a labeled native checkbox switch; wrapping it would nest interactive controls (axe).
16
- if (Platform.OS === 'web')
17
- return _jsxs(Inline, { children: [_jsx(Text, { children: label }), _jsx(RNSwitch, { accessibilityLabel: label, value: current, disabled: disabled, accessibilityState: { checked: current, disabled: !!disabled }, onValueChange: next => { if (!disabled)
18
- set(next); }, trackColor: track })] });
19
- return _jsxs(Pressable, { accessibilityRole: 'switch', accessibilityLabel: label, accessibilityState: { checked: current, disabled: !!disabled }, "aria-checked": current, "aria-disabled": !!disabled, disabled: disabled, onPress: () => { if (!disabled)
20
- set(!current); }, style: { direction: env.direction, minHeight: 48, flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', gap: tokens.space.md }, children: [_jsx(Text, { children: label }), _jsx(View, { pointerEvents: 'none', accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: _jsx(RNSwitch, { value: current, disabled: disabled, onValueChange: next => { if (!disabled)
21
- set(next); }, trackColor: track, thumbColor: thumb, ios_backgroundColor: colors.nested }) })] });
16
+ const web = Platform.OS === 'web';
17
+ const toggle = () => { if (!disabled)
18
+ set(!current); };
19
+ // One pressable row is the switch on every platform; what sits inside is decoration. iOS/Android show the platform track (Android
20
+ // otherwise paints the thumb with the app theme accent, Material teal, so it takes `text`). react-native-web's own Switch draws a
21
+ // Material thumb wider than its track in that off-palette teal and would nest a second control, so web draws the 40×24 capsule of
22
+ // @bloxwap/hig/react: an 18dp thumb inset 3dp that slides and eases over 150ms. RN Web presses on Enter; Space is handled here.
23
+ return _jsxs(Pressable, { accessibilityRole: 'switch', accessibilityLabel: label, accessibilityState: { checked: current, disabled: !!disabled }, "aria-checked": current, "aria-disabled": !!disabled, disabled: disabled, onPress: toggle, ...(web ? { onKeyDown: (event) => { if (event.key === ' ') {
24
+ event.preventDefault();
25
+ if (!event.repeat)
26
+ toggle();
27
+ } } } : null), style: { direction: env.direction, minHeight: 48, flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', gap: tokens.space.md, opacity: web && disabled ? 0.5 : 1 }, children: [_jsx(Text, { children: label }), _jsx(View, { pointerEvents: 'none', accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', "aria-hidden": web || undefined, style: web ? [{ width: 40, height: 24, borderRadius: 12, padding: 3, backgroundColor: track[current ? 'true' : 'false'] }, webEase] : undefined, children: web ? _jsx(View, { style: [{ width: 18, height: 18, borderRadius: 9, backgroundColor: current ? colors.onAction : colors.text, transform: [{ translateX: (current ? 16 : 0) * (env.direction === 'rtl' ? -1 : 1) }] }, webEase] }) : _jsx(RNSwitch, { value: current, disabled: disabled, onValueChange: next => { if (!disabled)
28
+ set(next); }, trackColor: track, thumbColor: Platform.OS === 'android' ? colors.text : undefined, ios_backgroundColor: fills.raised }) })] });
22
29
  }
23
30
  export { SwitchRow } from './switch-row.js';
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { type AddressKind } from './data.js';
3
+ export { VerticalAddress, addressKind, type AddressKind } from './data.js';
4
+ export interface WalletAddressProps {
5
+ address: string;
6
+ kind?: AddressKind;
7
+ /** QR payload when it differs from the address, e.g. an EIP-681 or Solana Pay URI. Defaults to the address. */
8
+ qrValue?: string;
9
+ /** Image URL shown in the centre of the QR. */
10
+ arena?: string;
11
+ /** QR edge in dp; default 196. */
12
+ size?: number;
13
+ /** Host clipboard adapter. When set the whole component is one button that copies the address and shows the Tap to copy hint. */
14
+ onCopy?: () => Promise<void> | void;
15
+ testID?: string;
16
+ }
17
+ /** The QR's drawing, in module units: three finder origins, one path of round dots for every other dark module, and the centre square left clear for an arena. */
18
+ export declare function qrGeometry(grid: readonly (readonly boolean[])[], withArena: boolean): {
19
+ edge: number;
20
+ finders: {
21
+ x: number;
22
+ y: number;
23
+ }[];
24
+ dots: string;
25
+ count: number;
26
+ arena: {
27
+ origin: number;
28
+ size: number;
29
+ } | null;
30
+ };
31
+ /**
32
+ * A wallet address to scan or copy: the QR in the cuer style (round dots, rounded finder patterns, no tile) beside the
33
+ * address as a monospace column exactly as tall as the code. Ethereum (`0x…`) lays out 6 characters a row and Solana 4.
34
+ * With `onCopy` the whole component is one button and a Tap to copy hint sits under it. Needs the optional `cuer` and
35
+ * `react-native-svg` peers; the encoder comes from `cuer/QrCode`, so React DOM is never loaded.
36
+ */
37
+ export declare function WalletAddress({ address, kind, qrValue, arena, size, onCopy, testID }: WalletAddressProps): React.JSX.Element;
@@ -0,0 +1,50 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useMemo } from 'react';
3
+ import { Image, Pressable, View } from 'react-native';
4
+ import Svg, { Path, Rect } from 'react-native-svg';
5
+ import { create } from 'cuer/QrCode';
6
+ import { useColors, useMessages } from './provider.js';
7
+ import { Text } from './surface.js';
8
+ import { Toast, useTransientNotice } from './status.js';
9
+ import { VerticalAddress, addressKind } from './data.js';
10
+ export { VerticalAddress, addressKind } from './data.js';
11
+ const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
12
+ /** The QR's drawing, in module units: three finder origins, one path of round dots for every other dark module, and the centre square left clear for an arena. */
13
+ export function qrGeometry(grid, withArena) {
14
+ const edge = grid.length, far = edge - 7, radius = 0.45, size = withArena ? Math.floor(edge / 4) : 0, origin = (edge - size) / 2;
15
+ const inFinder = (row, column) => (row < 7 && (column < 7 || column >= far)) || (row >= far && column < 7);
16
+ const inArena = (row, column) => size > 0 && row + 1 > origin && row < origin + size && column + 1 > origin && column < origin + size;
17
+ let dots = '', count = 0;
18
+ for (let row = 0; row < edge; row++)
19
+ for (let column = 0; column < edge; column++) {
20
+ if (!grid[row]?.[column] || inFinder(row, column) || inArena(row, column))
21
+ continue;
22
+ // One circle as two arcs, so the whole code is a single path.
23
+ dots += `M${column + 0.5 - radius} ${row + 0.5}a${radius} ${radius} 0 1 0 ${radius * 2} 0a${radius} ${radius} 0 1 0 ${-radius * 2} 0`;
24
+ count++;
25
+ }
26
+ return { edge, finders: [{ x: 0, y: 0 }, { x: far, y: 0 }, { x: 0, y: far }], dots, count, arena: size > 0 ? { origin, size } : null };
27
+ }
28
+ /** Two overlapping rounded squares: copy. */
29
+ function CopyIcon({ color }) { return _jsxs(View, { ...hidden, style: { width: 16, height: 16 }, children: [_jsx(View, { style: { position: 'absolute', left: 0, top: 0, width: 11, height: 11, borderRadius: 3, borderWidth: 1.5, borderColor: color } }), _jsx(View, { style: { position: 'absolute', right: 0, bottom: 0, width: 11, height: 11, borderRadius: 3, borderWidth: 1.5, borderColor: color } })] }); }
30
+ /**
31
+ * A wallet address to scan or copy: the QR in the cuer style (round dots, rounded finder patterns, no tile) beside the
32
+ * address as a monospace column exactly as tall as the code. Ethereum (`0x…`) lays out 6 characters a row and Solana 4.
33
+ * With `onCopy` the whole component is one button and a Tap to copy hint sits under it. Needs the optional `cuer` and
34
+ * `react-native-svg` peers; the encoder comes from `cuer/QrCode`, so React DOM is never loaded.
35
+ */
36
+ export function WalletAddress({ address, kind, qrValue, arena, size = 196, onCopy, testID }) {
37
+ const colors = useColors();
38
+ const t = useMessages();
39
+ const { notice, show, dismiss } = useTransientNotice();
40
+ const layout = kind ?? addressKind(address), rows = Math.max(1, Math.ceil(address.length / (layout === 'ethereum' ? 6 : 4)));
41
+ const value = qrValue ?? address, withArena = !!arena;
42
+ const qr = useMemo(() => qrGeometry(create(value, { errorCorrection: withArena ? 'high' : 'medium' }).grid, withArena), [value, withArena]);
43
+ const unit = size / qr.edge;
44
+ const code = _jsxs(View, { style: { width: size, height: size }, children: [_jsxs(Svg, { width: size, height: size, viewBox: `0 0 ${qr.edge} ${qr.edge}`, accessible: true, accessibilityRole: 'image', accessibilityLabel: t.qrCode, testID: 'wallet-address-qr', children: [qr.finders.map((finder, index) => _jsxs(React.Fragment, { children: [_jsx(Rect, { x: finder.x + 0.5, y: finder.y + 0.5, width: 6, height: 6, rx: 1.75, fill: 'none', stroke: colors.text, strokeWidth: 1 }), _jsx(Rect, { x: finder.x + 2, y: finder.y + 2, width: 3, height: 3, rx: 0.75, fill: colors.text })] }, index)), _jsx(Path, { d: qr.dots, fill: colors.text })] }), arena && qr.arena ? _jsx(Image, { ...hidden, source: { uri: arena }, testID: 'wallet-address-arena', style: { position: 'absolute', left: (qr.arena.origin + 0.5) * unit, top: (qr.arena.origin + 0.5) * unit, width: (qr.arena.size - 1) * unit, height: (qr.arena.size - 1) * unit, borderRadius: unit } }) : null] });
45
+ const body = _jsxs(_Fragment, { children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 16 }, children: [code, _jsx(VerticalAddress, { address: address, kind: layout, rowHeight: size / rows, testID: 'wallet-address-column' })] }), onCopy ? _jsxs(View, { ...hidden, style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8, marginTop: 12 }, children: [_jsx(CopyIcon, { color: colors.muted }), _jsx(Text, { style: { color: colors.muted, fontSize: 14, lineHeight: 21 }, children: t.tapToCopy })] }) : null] });
46
+ const copy = () => { if (!onCopy)
47
+ return; Promise.resolve().then(onCopy).then(() => show(t.addressCopied)).catch(() => { }); };
48
+ // The toast sits outside the button so its dismiss control is not nested in another control.
49
+ return _jsxs(View, { testID: testID, style: { alignItems: 'center' }, children: [onCopy ? _jsx(Pressable, { accessibilityRole: 'button', accessibilityLabel: `${t.copyAddress}: ${address}`, testID: 'wallet-address-copy', onPress: copy, style: ({ pressed }) => ({ opacity: pressed ? 0.8 : 1 }), children: body }) : _jsx(View, { children: body }), notice ? _jsx(View, { style: { marginTop: 8 }, children: _jsx(Toast, { notices: [notice], onDismiss: dismiss }) }) : null] });
50
+ }
@@ -1,6 +1,6 @@
1
1
  # @bloxwap/hig/native-fonts
2
2
 
3
- Version 0.2.0, an entry of `@bloxwap/hig`. Static Bloxwap Sans/Mono (and Korean/Simplified Chinese Sans) TTF faces for React Native and Expo hosts, derived reproducibly from pinned `@bloxwap/font` 0.1.2 by `npm run generate:fonts`.
3
+ Version 0.5.1, an entry of `@bloxwap/hig`. Static Bloxwap Sans/Mono (and Korean/Simplified Chinese Sans) TTF faces for React Native and Expo hosts, derived reproducibly from pinned `@bloxwap/font` 0.1.4 by `npm run generate:fonts`.
4
4
 
5
5
  Web hosts never import this entry: load fonts through `@bloxwap/font` and use `@bloxwap/hig/tokens/css`. Open Graph card renderers (Satori, `next/og`) use the much smaller `@bloxwap/hig/og-fonts` entry instead (#99).
6
6
 
@@ -16,7 +16,7 @@ export interface NativeFontManifest {
16
16
  }
17
17
  export declare const fontManifest: {
18
18
  readonly package: "@bloxwap/font";
19
- readonly version: "0.1.2";
19
+ readonly version: "0.1.4";
20
20
  readonly sources: {
21
21
  readonly "fonts/BloxwapSans/BloxwapSans-Variable.woff2": "96f6be58023b1d22152c797336282a4330a47ab4a3c0ab87451be887903746b7";
22
22
  readonly "fonts/BloxwapMono/BloxwapMono-Variable.woff2": "fa66e41575807c3d260d8f5b493be349cac127836b0174976c7d4876237d2632";
@@ -1,6 +1,6 @@
1
1
  export const fontManifest = {
2
2
  "package": "@bloxwap/font",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "sources": {
5
5
  "fonts/BloxwapSans/BloxwapSans-Variable.woff2": "96f6be58023b1d22152c797336282a4330a47ab4a3c0ab87451be887903746b7",
6
6
  "fonts/BloxwapMono/BloxwapMono-Variable.woff2": "fa66e41575807c3d260d8f5b493be349cac127836b0174976c7d4876237d2632",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@bloxwap/font",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "sources": {
5
5
  "fonts/BloxwapSans/BloxwapSans-Variable.woff2": "96f6be58023b1d22152c797336282a4330a47ab4a3c0ab87451be887903746b7",
6
6
  "fonts/BloxwapMono/BloxwapMono-Variable.woff2": "fa66e41575807c3d260d8f5b493be349cac127836b0174976c7d4876237d2632",
@@ -1,6 +1,6 @@
1
1
  # @bloxwap/hig/og-fonts
2
2
 
3
- Version 0.2.0, an entry of `@bloxwap/hig`. Five static Latin Bloxwap Sans/Mono TTF faces for Open Graph card renderers: Satori, `next/og` `ImageResponse` and `@vercel/og`. Satori reads TTF/OTF but not WOFF2, and `@bloxwap/font` ships only WOFF2.
3
+ Version 0.5.1, an entry of `@bloxwap/hig`. Five static Latin Bloxwap Sans/Mono TTF faces for Open Graph card renderers: Satori, `next/og` `ImageResponse` and `@vercel/og`. Satori reads TTF/OTF but not WOFF2, and `@bloxwap/font` ships only WOFF2.
4
4
 
5
5
  | Face | File | Weight |
6
6
  | --- | --- | --- |
@@ -31,4 +31,4 @@ This works in Next 16 route handlers with both the default Turbopack build and `
31
31
 
32
32
  Edge or Workers runtimes cannot read `node_modules` at request time. Copy `@bloxwap/hig/og-fonts/fonts/<asset>` into a build output at build time and check each file against `fontManifest.outputs[asset]` (also at `@bloxwap/hig/og-fonts/manifest`) before you write it. Keep that output gitignored.
33
33
 
34
- OFL attribution for the faces ships in `fonts/OFL.txt`. The faces derive from `@bloxwap/font` 0.1.2, and `fontManifest.sources` records the SHA-256 of its variable WOFF2 sources.
34
+ OFL attribution for the faces ships in `fonts/OFL.txt`. The faces derive from `@bloxwap/font` 0.1.4, and `fontManifest.sources` records the SHA-256 of its variable WOFF2 sources.
@@ -17,7 +17,7 @@ export interface OgFontManifest {
17
17
  }
18
18
  export declare const fontManifest: {
19
19
  readonly package: "@bloxwap/font";
20
- readonly version: "0.1.2";
20
+ readonly version: "0.1.4";
21
21
  readonly derivedFrom: "@bloxwap/hig/native-fonts";
22
22
  readonly sources: {
23
23
  readonly "fonts/BloxwapSans/BloxwapSans-Variable.woff2": "96f6be58023b1d22152c797336282a4330a47ab4a3c0ab87451be887903746b7";
@@ -1,6 +1,6 @@
1
1
  export const fontManifest = {
2
2
  "package": "@bloxwap/font",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "derivedFrom": "@bloxwap/hig/native-fonts",
5
5
  "sources": {
6
6
  "fonts/BloxwapSans/BloxwapSans-Variable.woff2": "96f6be58023b1d22152c797336282a4330a47ab4a3c0ab87451be887903746b7",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@bloxwap/font",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "derivedFrom": "@bloxwap/hig/native-fonts",
5
5
  "sources": {
6
6
  "fonts/BloxwapSans/BloxwapSans-Variable.woff2": "96f6be58023b1d22152c797336282a4330a47ab4a3c0ab87451be887903746b7",