@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,127 @@
1
+ import React from 'react';
2
+ import { type SwapWallet } from './swap/picker.js';
3
+ import { type SwapFee } from './swap/settings.js';
4
+ import { type SwapAction, type SwapChain, type SwapDenomination, type SwapToken, type SwapView } from './swap/shared.js';
5
+ export { swapAction, type SwapAction, type SwapChain, type SwapDenomination, type SwapToken, type SwapView } from './swap/shared.js';
6
+ export type { SwapWallet } from './swap/picker.js';
7
+ export type { SwapFee } from './swap/settings.js';
8
+ export { SwapAmountCard, type SwapAmountCardProps } from './swap/amount-card.js';
9
+ export { SwapPill, SwapKeypad } from './swap/shared.js';
10
+ /** A fixed place the assets go, in place of a token the user picks: a wallet, a staking pool, a trading account. Shown as a compact To card with no amount. */
11
+ export interface SwapDestination {
12
+ title: string;
13
+ /** One muted line above the title, such as the chain or a rate. */
14
+ subtitle?: string;
15
+ /** Image URL. Without one, `address` draws the wallet's colour disc. */
16
+ icon?: string;
17
+ /** A wallet address; shown shortened under the subtitle. */
18
+ address?: string;
19
+ /** Muted trailing text, such as an arrival time or a rate. */
20
+ detail?: string;
21
+ /** Makes the card a button with a trailing chevron, for example to change the recipient. */
22
+ onPress?: () => void;
23
+ /** Still to be chosen: the card shows `title` / `subtitle` as a placeholder and the action stays disabled, asking for a destination. */
24
+ pending?: boolean;
25
+ }
26
+ /** One label and value row of the details card. */
27
+ export interface SwapDetail {
28
+ label: string;
29
+ value: string;
30
+ }
31
+ /** The receive view: the host's address and its rendered QR code. HIG ships no QR encoder. */
32
+ export interface SwapReceive {
33
+ address: string;
34
+ qr?: React.ReactNode; /** Host clipboard adapter. When set, the whole view copies the address. */
35
+ onCopy?: () => Promise<void> | void;
36
+ }
37
+ export interface SwapPanelProps {
38
+ /** Catalog for the To side, and for the From side unless `fromTokens` is given. */
39
+ tokens: readonly SwapToken[];
40
+ /** Assets offered on the From side, typically the connected wallet's holdings. */
41
+ fromTokens?: readonly SwapToken[];
42
+ fromTokensLoading?: boolean;
43
+ /** Chain filter chips. Derived from the tokens, in first-seen order, when omitted. */
44
+ chains?: readonly SwapChain[];
45
+ /** Token ids for the picker's Hot section, in rank order. */
46
+ hotTokenIds?: readonly string[];
47
+ /** The chosen pair. Controlled when `from` / `to` is set (`null` is an empty side); otherwise the panel keeps it, seeded from the defaults. */
48
+ from?: SwapToken | null;
49
+ to?: SwapToken | null;
50
+ defaultFrom?: SwapToken | null;
51
+ defaultTo?: SwapToken | null;
52
+ onFromChange?: (token: SwapToken | null) => void;
53
+ onToChange?: (token: SwapToken | null) => void;
54
+ /** From amount in token units. Optional: set it to resync the entry, for example to `'0'` after a submit. */
55
+ amount?: string;
56
+ /** Reports the From amount in token units whenever the entry, denomination or price changes it. */
57
+ onAmountChange?: (units: string) => void;
58
+ /** To amount in token units from the host's quote. Until it arrives the panel shows a price estimate. */
59
+ received?: number | null;
60
+ /** Total fee in USD from the host's quote, and its breakdown for the settings sheet. */
61
+ fee?: number | null;
62
+ fees?: readonly SwapFee[];
63
+ quoteLoading?: boolean;
64
+ /** Slippage tolerance as a fraction (0.005 is 0.5%). Omit `onSlippageChange` to show it read-only. */
65
+ slippage?: number;
66
+ onSlippageChange?: (slippage: number) => void;
67
+ /** Default denomination of both amounts. Uncontrolled when omitted. */
68
+ denomination?: SwapDenomination;
69
+ onDenominationChange?: (denomination: SwapDenomination) => void;
70
+ wallet?: SwapWallet;
71
+ onConnect?: () => void;
72
+ onDisconnect?: () => void;
73
+ recipient?: string;
74
+ onRecipientChange?: (address: string) => void;
75
+ onScanRecipient?: () => void;
76
+ /** Enables the receive view, offered in the From picker before a wallet is connected. */
77
+ receive?: SwapReceive;
78
+ receiving?: boolean;
79
+ onReceivingChange?: (receiving: boolean) => void;
80
+ /** The host validates, quotes and executes. HIG never submits a transaction. */
81
+ onSubmit: (action: SwapAction) => void;
82
+ submitting?: boolean;
83
+ /** Called after the panel clears its entry and both tokens (through `onFromChange(null)` / `onToChange(null)`), so the host can drop its quote. */
84
+ onReset?: () => void;
85
+ /** `false` fixes both amounts to `denomination` (dollars by default): the conversion capsule under each amount and the denomination setting are not shown. For hosts that only have one of the two, for example no token price. */
86
+ denominationSwitch?: boolean;
87
+ /** A fixed destination in place of the To token. The To card becomes compact (no picker, no amount), the panel is one-way, and the action is ready once the From side is. `onSubmit` receives `'send'`. */
88
+ destination?: SwapDestination;
89
+ /** Label and value rows on the bottom card, such as a staked balance or a fee tier. With no To token and no destination they are the bottom card on their own, and the panel behaves as it does for a destination. */
90
+ details?: readonly SwapDetail[];
91
+ /** A line under the cards: a limit, a delay, a warning. `noteTone` tints it. */
92
+ note?: React.ReactNode;
93
+ noteTone?: 'muted' | 'warning' | 'negative';
94
+ /** Heading above the cards, for a panel that is its own screen or sheet (“Withdraw from Papertrade”). `onBack` adds a Back control beside it. */
95
+ title?: string;
96
+ onBack?: () => void;
97
+ /** `false` leaves the action button on its own, full width: no settings and no reset button. */
98
+ controls?: boolean;
99
+ /** Decoration before the action text. */
100
+ actionIcon?: React.ReactNode;
101
+ /** Keep a side's token fixed: its card shows the token but does not open the picker. Use with `from` / `to` or their defaults. */
102
+ lockFrom?: boolean;
103
+ lockTo?: boolean;
104
+ /** Names the action when it is ready, in place of Send, Swap or Bridge: for example Stake, Deposit or Withdraw. The host supplies the translated text. */
105
+ actionLabel?: string;
106
+ /** One direction only, top to bottom: the control between the cards becomes a down arrow instead of the flip button, and the pair cannot be exchanged. */
107
+ oneWay?: boolean;
108
+ /** `auto` shows the keypad for a coarse pointer (touch), where there is no hardware keyboard. */
109
+ keypad?: 'auto' | 'always' | 'never';
110
+ /** ⌘F / Ctrl+F opens the From picker and ⌘K / Ctrl+K the To picker while the panel is mounted. */
111
+ shortcuts?: boolean;
112
+ /** Digits typed anywhere on the page (outside a text field) drive the amount, not only inside the panel. */
113
+ captureKeyboard?: boolean;
114
+ /** The view on show. The panel pushes its token pickers and settings as views inside its own bounds; `main` is the cards. Uncontrolled when omitted. */
115
+ view?: SwapView;
116
+ onViewChange?: (view: SwapView) => void;
117
+ /** Host rows for the settings view, such as language or theme. */
118
+ settings?: React.ReactNode;
119
+ className?: string;
120
+ style?: React.CSSProperties;
121
+ }
122
+ /**
123
+ * Send, swap and bridge in one panel: a From card and a To card joined by a flip control, an amount entered in dollars
124
+ * or token units, token pickers, settings, and one action that names itself from the chosen pair.
125
+ * Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
126
+ */
127
+ export declare function SwapPanel({ tokens, fromTokens, fromTokensLoading, chains, hotTokenIds, from: fromProp, to: toProp, defaultFrom, defaultTo, onFromChange, onToChange, amount, onAmountChange, received, fee, fees, quoteLoading, slippage, onSlippageChange, denomination, onDenominationChange, wallet, onConnect, onDisconnect, recipient, onRecipientChange, onScanRecipient, receive, receiving, onReceivingChange, onSubmit, submitting, onReset, destination, details, note, noteTone, title, onBack, controls, actionIcon, lockFrom, lockTo, actionLabel, oneWay: oneWayProp, denominationSwitch, keypad, shortcuts, captureKeyboard, view: viewProp, onViewChange, settings, className, style }: SwapPanelProps): React.JSX.Element;
@@ -0,0 +1,170 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useMemo, useRef, useState } from 'react';
4
+ import { formatNumber } from '@bloxwap/hig/contracts';
5
+ import * as en from '@bloxwap/hig/contracts/messages';
6
+ import { useControllable, useHIG } from '../provider.js';
7
+ import { Button, IconButton } from '../button.js';
8
+ import { AnimatedNumberReadout } from '../animated-number.js';
9
+ import { notify } from '../notify.js';
10
+ import { VerticalAddress } from '../data.js';
11
+ import { SwapPicker } from './swap/picker.js';
12
+ import { SwapSettings } from './swap/settings.js';
13
+ import { SwapIcon, SwapKeypad, SwapPill, addressGradient, applyAmountKey, chainsOf, formatPercent, parentView, sanitizeAmount, shortAddress, swapAction, testAmount, trimNumber, unitsToEntry } from './swap/shared.js';
14
+ export { swapAction } from './swap/shared.js';
15
+ export { SwapAmountCard } from './swap/amount-card.js';
16
+ export { SwapPill, SwapKeypad } from './swap/shared.js';
17
+ const textTarget = (target) => { const element = target; return !!element && (/^(INPUT|TEXTAREA|SELECT)$/.test(element.tagName) || element.isContentEditable); };
18
+ const amountKey = (event) => event.metaKey || event.ctrlKey || event.altKey ? null : /^[0-9.]$/.test(event.key) ? event.key : event.key === 'Backspace' ? 'back' : null;
19
+ /**
20
+ * Send, swap and bridge in one panel: a From card and a To card joined by a flip control, an amount entered in dollars
21
+ * or token units, token pickers, settings, and one action that names itself from the chosen pair.
22
+ * Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
23
+ */
24
+ export function SwapPanel({ tokens, fromTokens, fromTokensLoading, chains, hotTokenIds, from: fromProp, to: toProp, defaultFrom = null, defaultTo = null, onFromChange, onToChange, amount, onAmountChange, received, fee, fees, quoteLoading, slippage = 0.005, onSlippageChange, denomination, onDenominationChange, wallet, onConnect, onDisconnect, recipient, onRecipientChange, onScanRecipient, receive, receiving, onReceivingChange, onSubmit, submitting = false, onReset, destination, details, note, noteTone = 'muted', title, onBack, controls = true, actionIcon, lockFrom = false, lockTo = false, actionLabel, oneWay: oneWayProp = false, denominationSwitch = true, keypad = 'auto', shortcuts = true, captureKeyboard = false, view: viewProp, onViewChange, settings, className, style }) {
25
+ const { messages, locale } = useHIG();
26
+ const [from, setFrom] = useControllable(fromProp, defaultFrom, onFromChange);
27
+ const [to, setTo] = useControllable(toProp, defaultTo, onToChange);
28
+ const [defaultMode, setDefaultMode] = useControllable(denomination, 'usd', onDenominationChange);
29
+ const [isReceiving, setReceiving] = useControllable(receiving, false, onReceivingChange);
30
+ // A mounted `amount` seeds the entry, in the default denomination at the initial From token's price.
31
+ const [entry, setEntry] = useState(() => amount === undefined ? '0' : unitsToEntry(Number(amount) || 0, defaultMode, from?.price ?? 0));
32
+ const [fromMode, applyFromMode] = useState(defaultMode);
33
+ const [toMode, applyToMode] = useState(defaultMode);
34
+ const [view, show] = useControllable(viewProp, 'main', onViewChange);
35
+ const root = useRef(null);
36
+ const previous = useRef('main');
37
+ const openPicker = (side) => show(side);
38
+ const back = () => show(parentView(view));
39
+ // A push slides in from the trailing edge and a pop from the leading edge. Popping to the cards returns focus to the control that pushed.
40
+ const direction = view === 'main' || (view === 'settings' && previous.current !== 'main') ? 'pop' : 'push';
41
+ useEffect(() => { const from = previous.current; previous.current = view; if (view !== 'main' || from === 'main')
42
+ return; root.current?.querySelector(from === 'from' || from === 'to' ? `[data-side='${from}'] .hig-swap-hit` : '.hig-swap-settings-button')?.focus(); }, [view]);
43
+ const [touch, setTouch] = useState(false);
44
+ const [hint, showHint] = useState(null);
45
+ const [copied, setCopied] = useState('');
46
+ useEffect(() => {
47
+ const coarse = window.matchMedia?.('(pointer: coarse)');
48
+ const update = () => setTouch(!!coarse?.matches);
49
+ update();
50
+ coarse?.addEventListener('change', update);
51
+ if (window.matchMedia?.('(hover: hover) and (pointer: fine)').matches)
52
+ showHint(/Mac|iPhone|iPad/.test(navigator.platform) ? 'mac' : 'pc');
53
+ return () => coarse?.removeEventListener('change', update);
54
+ }, []);
55
+ const fromPrice = from?.price ?? 0, toPrice = to?.price ?? 0, input = Number(entry) || 0;
56
+ const units = fromMode === 'token' ? input : fromPrice > 0 ? input / fromPrice : 0, usd = units * fromPrice, unitsText = trimNumber(units);
57
+ const showReceive = isReceiving && !!receive;
58
+ // Report the amount in token units; resync the entry when the host sets a different amount.
59
+ const reported = useRef(amount ?? '0');
60
+ useEffect(() => { if (reported.current !== unitsText) {
61
+ reported.current = unitsText;
62
+ onAmountChange?.(unitsText);
63
+ } }, [unitsText]);
64
+ useEffect(() => { if (amount === undefined || Number(amount) === Number(reported.current))
65
+ return; reported.current = trimNumber(Number(amount) || 0); setEntry(unitsToEntry(Number(amount) || 0, fromMode, fromPrice)); }, [amount]);
66
+ const sameAsset = !!from && !!to && from.id === to.id;
67
+ const receivedUnits = sameAsset ? units : received ?? (toPrice > 0 ? usd / toPrice : 0);
68
+ const receivedUsd = toPrice > 0 ? receivedUnits * toPrice : sameAsset ? usd : 0;
69
+ const action = swapAction(from, to);
70
+ const insufficient = !!from && (from.balance ?? 0) > 0 && units > (from.balance ?? 0);
71
+ // A destination or a details card stands in for the To token: one way, and ready from the From side alone.
72
+ const fixed = !!destination || (!!details && !to);
73
+ const oneWay = oneWayProp || fixed;
74
+ const ready = !!from && (!!to || fixed) && !destination?.pending && units > 0 && !insufficient;
75
+ const actionText = showReceive ? (messages.swapSendFromWallet ?? en.swapSendFromWallet) : !from || (!to && !fixed) ? (messages.swapChooseToken ?? en.swapChooseToken) : destination?.pending ? (messages.swapChooseDestination ?? en.swapChooseDestination) : units <= 0 ? (messages.swapEnterAmount ?? en.swapEnterAmount) : insufficient ? (messages.swapInsufficient ?? en.swapInsufficient)(from.symbol) : actionLabel ?? (action === 'swap' && !fixed ? messages.swapActionSwap ?? en.swapActionSwap : action === 'bridge' && !fixed ? messages.swapActionBridge ?? en.swapActionBridge : messages.swapActionSend ?? en.swapActionSend);
76
+ const pristine = (lockFrom || !from) && (lockTo || !to) && input === 0;
77
+ // Updater form: several keys can land before the next render, and each must build on the last.
78
+ const latest = useRef(fromMode);
79
+ latest.current = fromMode;
80
+ const latestView = useRef(view);
81
+ latestView.current = view;
82
+ const press = (key) => setEntry(current => applyAmountKey(current, key, latest.current));
83
+ const paste = (text) => { const clean = text.trim().replace(/,/g, ''); if (clean === '' || !/^[0-9]*\.?[0-9]*$/.test(clean))
84
+ return false; const next = sanitizeAmount(clean); setEntry(latest.current === 'usd' ? trimNumber(Number(next) || 0, 2) : next); return true; };
85
+ const switchFromMode = (mode) => { if (mode === fromMode)
86
+ return; setEntry(mode === 'usd' ? trimNumber(usd, 2) : trimNumber(units)); applyFromMode(mode); };
87
+ const changeDenomination = (mode) => { setDefaultMode(mode); switchFromMode(mode); applyToMode(mode); };
88
+ // A new default applies to an untouched entry at once; a typed amount keeps its denomination until reset.
89
+ useEffect(() => { if (input === 0) {
90
+ applyFromMode(defaultMode);
91
+ applyToMode(defaultMode);
92
+ } }, [defaultMode]);
93
+ const reset = () => { setEntry('0'); applyFromMode(defaultMode); applyToMode(defaultMode); if (isReceiving)
94
+ setReceiving(false); if (!lockFrom)
95
+ setFrom(null); if (!lockTo)
96
+ setTo(null); onReset?.(); };
97
+ const flip = () => { if (!from || !to)
98
+ return; setFrom(to); setTo(from); };
99
+ const submit = () => { if (submitting)
100
+ return; if (showReceive) {
101
+ onConnect?.();
102
+ return;
103
+ } if (ready)
104
+ onSubmit(fixed ? 'send' : action); };
105
+ const copyAddress = () => { if (!receive?.onCopy)
106
+ return; Promise.resolve().then(receive.onCopy).then(() => { const text = (messages.addressCopied ?? en.addressCopied); setCopied(notify(text, { severity: 'success', id: 'hig-swap-address', dismissName: (messages.dismissNotice ?? en.dismissNotice)(text, (messages.dismiss ?? en.dismiss)) }) ? text : ''); }).catch(() => setCopied('')); };
107
+ useEffect(() => {
108
+ if (!shortcuts && !captureKeyboard)
109
+ return;
110
+ const onKeyDown = (event) => {
111
+ const key = event.key.toLowerCase();
112
+ if (shortcuts && (event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey && (key === 'f' || key === 'k')) {
113
+ const side = key === 'f' ? 'from' : 'to';
114
+ if (side === 'from' ? lockFrom : lockTo || fixed)
115
+ return;
116
+ event.preventDefault();
117
+ show(side);
118
+ return;
119
+ }
120
+ if (!captureKeyboard || event.defaultPrevented || textTarget(event.target) || latestView.current !== 'main')
121
+ return;
122
+ const pressed = amountKey(event);
123
+ if (pressed) {
124
+ event.preventDefault();
125
+ press(pressed);
126
+ }
127
+ };
128
+ const onPaste = (event) => { if (captureKeyboard && !event.defaultPrevented && !textTarget(event.target) && paste(event.clipboardData?.getData('text') ?? ''))
129
+ event.preventDefault(); };
130
+ window.addEventListener('keydown', onKeyDown);
131
+ document.addEventListener('paste', onPaste);
132
+ return () => { window.removeEventListener('keydown', onKeyDown); document.removeEventListener('paste', onPaste); };
133
+ }, [shortcuts, captureKeyboard, lockFrom, lockTo, fixed]);
134
+ // Keys typed while focus is inside the cards drive the amount; in a pushed view Escape pops it.
135
+ const inPanel = (event) => view === 'main' && !textTarget(event.target);
136
+ const onKeyDown = (event) => { if (view !== 'main' && event.key === 'Escape') {
137
+ event.preventDefault();
138
+ event.stopPropagation();
139
+ back();
140
+ return;
141
+ } if (captureKeyboard || !inPanel(event))
142
+ return; const pressed = amountKey(event); if (pressed) {
143
+ event.preventDefault();
144
+ press(pressed);
145
+ } };
146
+ const onPaste = (event) => { if (!captureKeyboard && inPanel(event) && paste(event.clipboardData.getData('text')))
147
+ event.preventDefault(); };
148
+ const chainList = useMemo(() => chains ?? chainsOf(tokens), [chains, tokens]);
149
+ const usdText = (value) => formatNumber(value, locale, { style: 'currency', currency: 'USD' });
150
+ const fraction = entry.includes('.') ? Math.min(entry.length - entry.indexOf('.') - 1, fromMode === 'usd' ? 2 : 8) : 0;
151
+ // An account (a token with a `caption`) reads name over caption beside one disc, and offers Max only.
152
+ const account = (side, token, locked) => _jsxs("div", { className: 'hig-swap-selected', "data-account": 'true', children: [_jsx("span", { className: 'hig-swap-stack', "aria-hidden": 'true', children: token.icon ? _jsx("img", { src: token.icon, alt: '' }) : _jsx("span", { className: 'hig-swap-initials', children: token.symbol.slice(0, 3) }) }), _jsxs("span", { className: 'hig-swap-identity', children: [_jsxs("strong", { children: [token.name, !locked && _jsx(SwapIcon, { name: 'expand', size: 16 })] }), _jsx("span", { children: token.caption })] }), side === 'from' && (token.balance ?? 0) > 0 && _jsx("span", { className: 'hig-swap-meta', children: _jsx(SwapPill, { onClick: () => setEntry(unitsToEntry(token.balance ?? 0, fromMode, fromPrice)), children: (messages.swapMax ?? en.swapMax) }) })] });
153
+ const header = (side, token) => _jsxs("div", { className: 'hig-swap-selected', children: [_jsxs("span", { className: 'hig-swap-stack', "aria-hidden": 'true', children: [wallet?.address && _jsx("span", { className: 'hig-swap-avatar', style: { background: addressGradient(wallet.address) } }), token.chainIcon && _jsx("img", { src: token.chainIcon, alt: '' }), token.icon ? _jsx("img", { src: token.icon, alt: '' }) : _jsx("span", { className: 'hig-swap-initials', children: token.symbol.slice(0, 3) })] }), _jsxs("span", { className: 'hig-swap-identity', children: [wallet?.address && _jsx("span", { children: shortAddress(wallet.address) }), _jsx("span", { children: token.chain }), _jsx("strong", { children: token.name })] }), side === 'from' ? (token.balance ?? 0) > 0 && _jsxs("span", { className: 'hig-swap-meta', children: [_jsxs("span", { className: 'hig-swap-pills', children: [_jsxs(SwapPill, { onClick: () => setEntry(unitsToEntry(testAmount(token), fromMode, fromPrice)), children: [_jsx(SwapIcon, { name: 'flask', size: 14 }), (messages.swapTest ?? en.swapTest)] }), _jsx(SwapPill, { onClick: () => setEntry(unitsToEntry(token.balance ?? 0, fromMode, fromPrice)), children: (messages.swapMax ?? en.swapMax) })] }), _jsxs("span", { className: 'hig-number', children: [formatNumber(token.balance, locale, { maximumFractionDigits: 6 }), " ", token.symbol] })] })
154
+ : _jsxs("span", { className: 'hig-swap-meta', children: [_jsxs(SwapPill, { onClick: () => show(onSlippageChange ? 'slippage' : 'settings'), children: [_jsx(SwapIcon, { name: 'sliders', size: 14 }), (messages.swapSlippage ?? en.swapSlippage)(formatPercent(slippage))] }), _jsx("span", { children: (messages.swapFee ?? en.swapFee)(quoteLoading ? '…' : fee != null ? usdText(fee) : '—') })] })] });
155
+ const receiveView = (view) => { const content = _jsxs(_Fragment, { children: [view.qr && _jsx("span", { className: 'hig-swap-qr', children: view.qr }), _jsx(VerticalAddress, { address: view.address })] }); return view.onCopy ? _jsx("button", { type: 'button', className: 'hig-swap-receive', "aria-label": (messages.copyAddress ?? en.copyAddress) + ': ' + view.address, onClick: copyAddress, children: content }) : _jsx("div", { className: 'hig-swap-receive', children: content }); };
156
+ const card = (side) => {
157
+ const token = side === 'from' ? from : to, label = side === 'from' ? (messages.swapFrom ?? en.swapFrom) : (messages.swapTo ?? en.swapTo), mode = side === 'from' ? fromMode : toMode, locked = side === 'from' ? lockFrom : lockTo;
158
+ const cardUnits = side === 'from' ? units : receivedUnits, cardUsd = side === 'from' ? usd : receivedUsd;
159
+ const shown = side === 'from' ? input : mode === 'token' ? receivedUnits : receivedUsd;
160
+ return _jsxs("div", { className: 'hig-swap-card', "data-side": side, "data-locked": locked || undefined, children: [_jsxs("div", { className: 'hig-swap-slot', children: [!locked && _jsx("button", { type: 'button', className: 'hig-swap-hit', "aria-label": (messages.swapSelectToken ?? en.swapSelectToken)(label), onClick: () => openPicker(side) }), _jsx("div", { className: 'hig-swap-slot-content', children: token ? token.caption !== undefined ? account(side, token, locked) : header(side, token) : _jsxs(_Fragment, { children: [_jsxs("span", { className: 'hig-swap-placeholder', children: [label, "\u2026"] }), shortcuts && hint && !locked && _jsxs("kbd", { className: 'hig-swap-kbd', children: [hint === 'mac' ? '⌘' : messages.swapControlKey ?? en.swapControlKey, " ", side === 'from' ? 'F' : 'K'] })] }) })] }), side === 'from' && showReceive && receive ? receiveView(receive) :
161
+ !(side === 'to' && showReceive) && _jsxs("div", { className: 'hig-swap-amount-area', children: [!locked && _jsx("button", { type: 'button', className: 'hig-swap-hit', tabIndex: -1, "aria-hidden": 'true', onClick: () => openPicker(side) }), _jsxs("div", { className: 'hig-swap-amount-content', children: [_jsx("div", { className: 'hig-swap-amount', "data-muted": side === 'to' || undefined, ...(side === 'from' ? { role: 'textbox', tabIndex: 0, 'aria-label': (messages.swapAmount ?? en.swapAmount)(label) } : {}), children: _jsx(AnimatedNumberReadout, { value: shown, label: side === 'to' ? (messages.swapAmount ?? en.swapAmount)(label) : undefined, prefix: mode === 'usd' ? '$' : '', suffix: side === 'from' && entry.endsWith('.') ? '.' : '', options: { minimumFractionDigits: side === 'from' ? fraction : 0, maximumFractionDigits: mode === 'usd' ? 2 : 8, useGrouping: false } }) }), denominationSwitch && _jsxs(SwapPill, { "aria-label": (messages.swapSwitchDenomination ?? en.swapSwitchDenomination), onClick: () => side === 'from' ? switchFromMode(fromMode === 'usd' ? 'token' : 'usd') : applyToMode(toMode === 'usd' ? 'token' : 'usd'), children: [_jsx("span", { "aria-hidden": 'true', className: 'hig-swap-equals', children: "=" }), mode === 'token' ? _jsx(AnimatedNumberReadout, { value: cardUsd, options: { style: 'currency', currency: 'USD' } }) : _jsx(AnimatedNumberReadout, { value: cardUnits, suffix: token ? ` ${token.symbol}` : '', options: { maximumFractionDigits: 8, useGrouping: false } }), _jsx(SwapIcon, { name: 'flip', size: 14 })] })] })] })] });
162
+ };
163
+ // The fixed bottom card is one compact row for the destination (artwork, where it goes, a trailing detail and fee), label and value rows, or both.
164
+ const fixedCard = fixed && _jsxs("div", { className: 'hig-swap-card', "data-side": 'to', "data-compact": 'true', "data-pending": destination?.pending || undefined, children: [destination && _jsxs("div", { className: 'hig-swap-slot', children: [destination.onPress && _jsx("button", { type: 'button', className: 'hig-swap-hit', "aria-label": destination.title, onClick: destination.onPress }), _jsx("div", { className: 'hig-swap-slot-content', children: _jsxs("div", { className: 'hig-swap-selected', children: [_jsx("span", { className: 'hig-swap-stack', "aria-hidden": 'true', children: destination.icon ? _jsx("img", { src: destination.icon, alt: '' }) : destination.address ? _jsx("span", { className: 'hig-swap-avatar', style: { background: addressGradient(destination.address) } }) : _jsx("span", { className: 'hig-swap-initials', children: destination.title.slice(0, 2) }) }), _jsxs("span", { className: 'hig-swap-identity', children: [_jsx("strong", { children: destination.title }), destination.subtitle && _jsx("span", { children: destination.subtitle }), destination.address && _jsx("span", { children: shortAddress(destination.address) })] }), (destination.detail || fee !== undefined || destination.onPress) && _jsxs("span", { className: 'hig-swap-meta', "data-row": destination.onPress ? 'true' : undefined, children: [_jsxs("span", { children: [destination.detail && _jsx("span", { children: destination.detail }), fee !== undefined && _jsx("span", { children: (messages.swapFee ?? en.swapFee)(quoteLoading ? '…' : fee != null ? usdText(fee) : '—') })] }), destination.onPress && _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] }) })] }), details && details.length > 0 && _jsx("dl", { className: 'hig-swap-details', children: details.map(row => _jsxs("div", { children: [_jsx("dt", { children: row.label }), _jsx("dd", { children: row.value })] }, row.label)) })] });
165
+ const fromCard = card('from'), toCard = fixedCard || card('to');
166
+ const body = view === 'main' ? _jsxs(_Fragment, { children: [title && _jsxs("div", { className: 'hig-swap-view-header', "data-plain": onBack ? undefined : 'true', children: [onBack && _jsx("button", { type: 'button', className: 'hig-swap-back', "aria-label": messages.back ?? en.back, onClick: onBack, children: _jsx(SwapIcon, { name: 'back' }) }), _jsx("h2", { className: 'hig-swap-view-title', children: title })] }), fromCard, _jsx("div", { className: 'hig-swap-flip', children: oneWay ? _jsx("span", { "aria-hidden": 'true', children: _jsx(SwapIcon, { name: 'down', size: 16 }) }) : _jsx("button", { type: 'button', "aria-label": (messages.swapFlip ?? en.swapFlip), disabled: !from || !to, onClick: flip, children: _jsx(SwapIcon, { name: 'flip', size: 16 }) }) }), toCard, !showReceive && (keypad === 'always' || (keypad === 'auto' && touch)) && _jsx(SwapKeypad, { onKey: press, label: (messages.swapKeypad ?? en.swapKeypad), deleteLabel: (messages.swapDelete ?? en.swapDelete) }), note && _jsx("p", { className: 'hig-swap-note', "data-tone": noteTone, role: 'note', children: note }), _jsxs("div", { className: 'hig-swap-actions', children: [controls && _jsx(IconButton, { className: 'hig-swap-settings-button', intent: 'secondary', label: (messages.swapSettings ?? en.swapSettings), suppressFeedback: true, onClick: () => show('settings'), children: _jsx(SwapIcon, { name: 'menu' }) }), _jsxs(Button, { fullWidth: true, busy: submitting, disabled: !showReceive && !ready, onClick: submit, children: [actionIcon, actionText] }), controls && _jsx(IconButton, { intent: 'secondary', label: (messages.swapReset ?? en.swapReset), disabled: pristine || submitting, onClick: reset, children: _jsx(SwapIcon, { name: 'reset' }) })] })] }) : view === 'from' ? _jsx(SwapPicker, { side: view, onBack: back, tokens: fromTokens ?? tokens, loading: fromTokensLoading, chains: chainList, hotTokenIds: hotTokenIds, selected: from, onSelect: setFrom, wallet: wallet, onConnect: onConnect, onDisconnect: onDisconnect, receiving: isReceiving, onReceivingChange: receive ? setReceiving : undefined })
167
+ : view === 'to' ? _jsx(SwapPicker, { side: view, onBack: back, tokens: tokens, chains: chainList, hotTokenIds: hotTokenIds, selected: to, onSelect: setTo, wallet: wallet, recipient: recipient, onRecipientChange: onRecipientChange, onScanRecipient: onScanRecipient })
168
+ : _jsx(SwapSettings, { view: view, onViewChange: show, onBack: back, denomination: defaultMode, onDenominationChange: denominationSwitch ? changeDenomination : undefined, slippage: slippage, onSlippageChange: onSlippageChange, fee: fee, fees: fees, quoteLoading: quoteLoading, children: settings });
169
+ return _jsxs("section", { ref: root, className: `hig-swap-panel${className ? ` ${className}` : ''}`, style: style, "data-view": view, "data-receiving": showReceive || undefined, onKeyDown: onKeyDown, onPaste: onPaste, children: [_jsx("div", { className: 'hig-swap-view', "data-direction": direction, children: body }, view), _jsx("p", { className: 'hig-sr-only', role: 'status', children: copied })] });
170
+ }
@@ -0,0 +1,16 @@
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; not drawn. */
7
+ title: string;
8
+ /** One element that opens the sheet and accepts a ref. */
9
+ trigger?: React.ReactNode;
10
+ }
11
+ /**
12
+ * SwapPanel presented in a gesture sheet (Vaul). Token pickers and settings push inside the same sheet, which resizes to
13
+ * each view. Escape and Back pop a pushed view first; from the cards, Escape, the scrim and a downward drag close the sheet.
14
+ * Lives in its own entry so the recipes aggregate stays free of the optional Vaul peer.
15
+ */
16
+ export declare function SwapSheet({ open, onOpenChange, title, trigger, view: viewProp, onViewChange, ...panel }: SwapSheetProps): React.JSX.Element;
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect } from 'react';
4
+ import { useControllable } from '../provider.js';
5
+ import { GestureSheet } from '../gesture-sheet.js';
6
+ import { SwapPanel } from './swap-panel.js';
7
+ import { parentView } from './swap/shared.js';
8
+ /**
9
+ * SwapPanel presented in a gesture sheet (Vaul). Token pickers and settings push inside the same sheet, which resizes to
10
+ * each view. Escape and Back pop a pushed view first; from the cards, Escape, the scrim and a downward drag close the sheet.
11
+ * Lives in its own entry so the recipes aggregate stays free of the optional Vaul peer.
12
+ */
13
+ export function SwapSheet({ open, onOpenChange, title, trigger, view: viewProp, onViewChange, ...panel }) {
14
+ const [view, show] = useControllable(viewProp, 'main', onViewChange);
15
+ // A reopened sheet starts on the cards, not on the view it was closed from.
16
+ useEffect(() => { if (!open && view !== 'main')
17
+ show('main'); }, [open]);
18
+ return _jsx(GestureSheet, { open: open, onOpenChange: onOpenChange, title: title, titleHidden: true, trigger: trigger, closeButton: null, contentMode: 'custom', enableDynamicSizing: true, contentProps: { className: 'hig-swap-sheet', onEscapeKeyDown: event => { if (view !== 'main') {
19
+ event.preventDefault();
20
+ show(parentView(view));
21
+ } } }, children: _jsx(SwapPanel, { ...panel, view: view, onViewChange: show }) });
22
+ }
@@ -9,4 +9,4 @@ import { Field, AmountInput } from '../field.js';
9
9
  import { Dialog } from '../dialog.js';
10
10
  import { Alert } from '../status.js';
11
11
  /** Host validates and submits. Opening review never submits a transaction. */
12
- 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, onChange: e => onAmountChange(e.target.value), readOnly: busy }) }), _jsx(Button, { fullWidth: true, disabled: !amount || !!error, busy: busy, onClick: () => 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, onClick: onConfirm, children: messages.confirmOrder ?? en.confirmOrder }), error && _jsx(Alert, { title: messages.orderUnavailable ?? en.orderUnavailable, severity: 'error', children: _jsx("p", { children: error }) })] })] }) }); }
12
+ 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, onChange: e => onAmountChange(e.target.value), readOnly: busy }) }), _jsx(Button, { fullWidth: true, className: 'hig-form-action', disabled: !amount || !!error, busy: busy, onClick: () => 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, onClick: onConfirm, children: messages.confirmOrder ?? en.confirmOrder }), error && _jsx(Alert, { title: messages.orderUnavailable ?? en.orderUnavailable, severity: 'error', children: _jsx("p", { children: error }) })] })] }) }); }
@@ -1,4 +1,4 @@
1
- /** Aggregate entry. TradeEntry needs @radix-ui/react-dialog; import single recipes from `@bloxwap/hig/react/recipes/<name>` to avoid overlay peers. */
1
+ /** Aggregate entry. TradeEntry needs @radix-ui/react-dialog; import single recipes from `@bloxwap/hig/react/recipes/<name>` to avoid overlay peers. SwapSheet (Vaul) is only at `recipes/swap-sheet`. */
2
2
  export { MarketRow } from './recipes/market-row.js';
3
3
  export { BalanceCard } from './recipes/balance-card.js';
4
4
  export { TradeEntry } from './recipes/trade-entry.js';
@@ -6,3 +6,5 @@ export { InstallCommand } from './recipes/install-command.js';
6
6
  export { CodeWindow } from './recipes/code-window.js';
7
7
  export { MarketingHero } from './recipes/marketing-hero.js';
8
8
  export { ActivityList } from './recipes/activity-list.js';
9
+ export { FromPicker, ToPicker, type FromPickerProps, type ToPickerProps, type PickerListProps } from './recipes/pickers.js';
10
+ export { SwapPanel, swapAction, type SwapPanelProps, type SwapToken, type SwapChain, type SwapAction, type SwapDenomination, type SwapWallet, type SwapFee, type SwapReceive, type SwapDestination, type SwapDetail } from './recipes/swap-panel.js';
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- /** Aggregate entry. TradeEntry needs @radix-ui/react-dialog; import single recipes from `@bloxwap/hig/react/recipes/<name>` to avoid overlay peers. */
2
+ /** Aggregate entry. TradeEntry needs @radix-ui/react-dialog; import single recipes from `@bloxwap/hig/react/recipes/<name>` to avoid overlay peers. SwapSheet (Vaul) is only at `recipes/swap-sheet`. */
3
3
  export { MarketRow } from './recipes/market-row.js';
4
4
  export { BalanceCard } from './recipes/balance-card.js';
5
5
  export { TradeEntry } from './recipes/trade-entry.js';
@@ -7,3 +7,5 @@ export { InstallCommand } from './recipes/install-command.js';
7
7
  export { CodeWindow } from './recipes/code-window.js';
8
8
  export { MarketingHero } from './recipes/marketing-hero.js';
9
9
  export { ActivityList } from './recipes/activity-list.js';
10
+ export { FromPicker, ToPicker } from './recipes/pickers.js';
11
+ export { SwapPanel, swapAction } from './recipes/swap-panel.js';
@@ -120,6 +120,8 @@ export function Select({ label, options, value, defaultValue, disabled, onValueC
120
120
  const desired = Math.min(320, popup.scrollHeight || 320);
121
121
  const upwards = below < desired && above > below;
122
122
  const maxHeight = Math.max(0, Math.min(320, upwards ? above : below));
123
+ // The presenting animation settles from the edge nearest the trigger.
124
+ popup.dataset.placement = upwards ? 'top' : 'bottom';
123
125
  const popupWidth = Math.min(rect.width, Math.max(0, width - inset * 2));
124
126
  popup.style.width = `${popupWidth}px`;
125
127
  popup.style.maxHeight = `${maxHeight}px`;
@@ -23,5 +23,18 @@ export interface ChoicesProps {
23
23
  }
24
24
  export declare function RadioGroup({ label, options, value, defaultValue, disabled, onValueChange }: ChoicesProps): React.JSX.Element;
25
25
  export declare function SegmentedControl({ label, options, value, defaultValue, disabled, onValueChange }: ChoicesProps): React.JSX.Element;
26
+ export interface FilterOption extends Choice {
27
+ icon?: string;
28
+ }
29
+ export interface FilterProps {
30
+ label: string;
31
+ options: readonly FilterOption[];
32
+ value?: string;
33
+ defaultValue?: string;
34
+ disabled?: boolean;
35
+ onValueChange?: (value: string) => void;
36
+ }
37
+ /** One row of filter capsules that scrolls sideways. Single choice with radio semantics; the chosen capsule inverts and a check draws into its circle. */
38
+ export declare function Filter({ label, options, value, defaultValue, disabled, onValueChange }: FilterProps): React.JSX.Element;
26
39
  export { Select } from './select.js';
27
40
  export { Slider } from './slider.js';
@@ -12,5 +12,12 @@ export function SegmentedControl({ label, options, value, defaultValue = '', dis
12
12
  return _jsxs("fieldset", { className: 'hig-group hig-segmented-control', disabled: disabled, children: [_jsx("legend", { children: label }), _jsxs("div", { className: 'hig-segments', style: { '--hig-segment-count': Math.max(1, options.length), '--hig-segment-index': selected }, children: [selected >= 0 && _jsx("span", { className: 'hig-segment-indicator', "aria-hidden": 'true', "data-disabled": disabled || options[selected].disabled || undefined }), options.map(o => _jsxs("label", { className: 'hig-segment', children: [_jsx("input", { type: 'radio', name: name, value: o.value, checked: current === o.value, disabled: o.disabled, onChange: () => { if (!disabled && !o.disabled)
13
13
  set(o.value); } }), _jsx("span", { children: o.label })] }, o.value))] })] });
14
14
  }
15
+ /** One row of filter capsules that scrolls sideways. Single choice with radio semantics; the chosen capsule inverts and a check draws into its circle. */
16
+ export function Filter({ label, options, value, defaultValue = '', disabled, onValueChange }) {
17
+ const name = useId();
18
+ const [current, set] = useControllable(value, defaultValue, onValueChange);
19
+ return _jsx("div", { className: 'hig-filter', role: 'radiogroup', "aria-label": label, "aria-disabled": disabled || undefined, children: options.map(o => _jsxs("label", { className: 'hig-filter-chip', children: [_jsx("input", { type: 'radio', name: name, value: o.value, checked: current === o.value, disabled: disabled || o.disabled, onChange: () => { if (!disabled && !o.disabled)
20
+ set(o.value); } }), _jsxs("span", { className: 'hig-filter-mark', "aria-hidden": 'true', children: [o.icon && _jsx("img", { src: o.icon, alt: '', loading: 'lazy' }), _jsx("svg", { viewBox: '0 0 16 16', focusable: 'false', children: _jsx("path", { pathLength: '1', d: 'm3.75 8.5 2.75 2.75 5.75-6.25' }) })] }), _jsx("span", { children: o.label })] }, o.value)) });
21
+ }
15
22
  export { Select } from './select.js';
16
23
  export { Slider } from './slider.js';
@@ -5,9 +5,9 @@ export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
5
5
  }
6
6
  /** A quiet status label. The host owns announcements and may supply typography or an accessible name. */
7
7
  export declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLSpanElement>>;
8
- /** `note` and `tip` are documentation callout severities: note uses the `info` token role and tip the `positive` role, like info and success. `default` is the neutral variant: border token stroke with a soft white glow instead of a tone. */
8
+ /** `note` and `tip` are documentation callout severities: note uses the `info` token role and tip the `positive` role, like info and success. `default` is the neutral variant: a faint `text` tint with the title in `text`. */
9
9
  export type AlertSeverity = 'default' | 'info' | 'success' | 'warning' | 'error' | 'note' | 'tip';
10
- /** Severity sets the glowing stroke from a token role (default → border, info/note → info, success/tip → positive, warning → warning, error → negative): a 2px tone border with a matching glow on a translucent surface. The title may be any inline node, such as text with a code span. */
10
+ /** Severity tints the fill 10% and colours the title from a token role (info/note → info, success/tip → positive, warning → warning, error → negative; default → 6% of text), with no stroke or glow. The title may be any inline node, such as text with a code span. */
11
11
  export declare function Alert({ title, children, severity, action, announce }: React.PropsWithChildren<{
12
12
  title: React.ReactNode;
13
13
  severity?: AlertSeverity;
@@ -21,10 +21,18 @@ export interface Notice {
21
21
  severity: 'info' | 'success' | 'warning' | 'error';
22
22
  action?: React.ReactNode;
23
23
  }
24
+ /** One notice as a single capsule row: severity symbol on the leading edge, message, optional action, close on the trailing edge. Shared by `Toast` and the Sonner-backed `toast()`; it announces nothing itself. */
25
+ export declare function ToastNotice({ message, severity, action, dismissName, onDismiss }: {
26
+ message: React.ReactNode;
27
+ severity?: Notice['severity'];
28
+ action?: React.ReactNode; /** Accessible name of the close button. */
29
+ dismissName: string;
30
+ onDismiss: () => void;
31
+ }): React.JSX.Element;
24
32
  /** Persistent until dismissed; host deduplicates ids, critical messages remain inline. */
25
33
  export declare function Toast({ notices, onDismiss, dismissLabel }: {
26
34
  notices: readonly Notice[];
27
- onDismiss: (id: string) => void; /** Dismiss button text; defaults to HIGProvider `messages.dismiss`. The accessible name comes from `messages.dismissNotice` and contains it. */
35
+ onDismiss: (id: string) => void; /** Dismiss wording inside the close button's accessible name (`messages.dismissNotice`); the button itself draws a close symbol. Defaults to HIGProvider `messages.dismiss`. */
28
36
  dismissLabel?: string;
29
37
  }): React.JSX.Element;
30
38
  export declare function Progress({ label, value, max }: {
@@ -38,10 +46,12 @@ export declare function Spinner({ label }: {
38
46
  export declare function Skeleton({ label }: {
39
47
  label?: string;
40
48
  }): React.JSX.Element;
41
- export declare function EmptyState({ title, description, action }: {
49
+ /** Centred stack: symbol, title, optional description, optional action. Decorative `illustration` replaces the default symbol (same prop as native); `null` omits it. */
50
+ export declare function EmptyState({ title, description, action, illustration }: {
42
51
  title: string;
43
- description: string;
52
+ description?: string;
44
53
  action?: React.ReactNode;
54
+ illustration?: React.ReactNode;
45
55
  }): React.JSX.Element;
46
56
  export declare function Avatar({ name, src }: {
47
57
  name: string;
@@ -2,14 +2,16 @@
2
2
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import React, { useEffect, useRef, useState } from 'react';
4
4
  import { notificationDelta } from '@bloxwap/hig/contracts/announcements';
5
- import { Button } from './button.js';
6
5
  import * as en from '@bloxwap/hig/contracts/messages';
7
6
  import { useHIG } from './provider.js';
8
7
  /** A quiet status label. The host owns announcements and may supply typography or an accessible name. */
9
8
  export const Badge = React.forwardRef(function Badge({ children, tone = 'neutral', className, ...props }, ref) { const accent = ['positive', 'negative', 'warning', 'info'].includes(tone) ? tone : undefined; return _jsx("span", { ...props, ref: ref, className: ['hig-badge', className].filter(Boolean).join(' '), "data-tone": accent, children: children }); });
10
- /** Severity sets the glowing stroke from a token role (default → border, info/note → info, success/tip → positive, warning → warning, error → negative): a 2px tone border with a matching glow on a translucent surface. The title may be any inline node, such as text with a code span. */
9
+ /** Severity tints the fill 10% and colours the title from a token role (info/note → info, success/tip → positive, warning → warning, error → negative; default → 6% of text), with no stroke or glow. The title may be any inline node, such as text with a code span. */
11
10
  export function Alert({ title, children, severity = 'info', action, announce = true }) { return _jsxs("section", { className: 'hig-surface hig-alert', "data-severity": severity, role: announce ? (severity === 'error' ? 'alert' : 'status') : undefined, children: [_jsx("strong", { children: title }), children, action != null && _jsx("div", { className: 'hig-alert-actions', children: action })] }); }
12
11
  export const Callout = Alert;
12
+ const noticeSymbol = { info: _jsxs(_Fragment, { children: [_jsx("circle", { cx: '10', cy: '10', r: '7.25' }), _jsx("path", { d: 'M10 9.25v4.25M10 6.5v.01' })] }), success: _jsxs(_Fragment, { children: [_jsx("circle", { cx: '10', cy: '10', r: '7.25' }), _jsx("path", { d: 'm6.75 10.25 2.25 2.25 4.25-4.5' })] }), warning: _jsxs(_Fragment, { children: [_jsx("path", { d: 'M10 3.5 17.25 16H2.75Z' }), _jsx("path", { d: 'M10 8.5v3.25M10 14v.01' })] }), error: _jsxs(_Fragment, { children: [_jsx("circle", { cx: '10', cy: '10', r: '7.25' }), _jsx("path", { d: 'm7.5 7.5 5 5m0-5-5 5' })] }) };
13
+ /** One notice as a single capsule row: severity symbol on the leading edge, message, optional action, close on the trailing edge. Shared by `Toast` and the Sonner-backed `toast()`; it announces nothing itself. */
14
+ export function ToastNotice({ message, severity = 'info', action, dismissName, onDismiss }) { return _jsxs("div", { className: 'hig-toast-item', "data-severity": severity, children: [_jsx("svg", { className: 'hig-toast-icon', "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', children: noticeSymbol[severity] ?? noticeSymbol.info }), _jsx("span", { className: 'hig-toast-message', children: message }), action, _jsx("button", { type: 'button', className: 'hig-toast-close', "aria-label": dismissName, onClick: onDismiss, children: _jsx("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', children: _jsx("path", { d: 'm5.5 5.5 9 9m0-9-9 9' }) }) })] }); }
13
15
  /** Persistent until dismissed; host deduplicates ids, critical messages remain inline. */
14
16
  export function Toast({ notices, onDismiss, dismissLabel }) {
15
17
  const { messages } = useHIG();
@@ -33,11 +35,13 @@ export function Toast({ notices, onDismiss, dismissLabel }) {
33
35
  }, [key]);
34
36
  useEffect(() => () => { if (timer.current !== null)
35
37
  clearTimeout(timer.current); }, []);
36
- return _jsxs("aside", { className: 'hig-toast', "aria-label": messages.notifications ?? en.notifications, children: [unique.map(n => _jsx(Alert, { announce: false, title: n.message, severity: n.severity, action: _jsxs(_Fragment, { children: [n.action, _jsx(Button, { intent: 'ghost', "aria-label": (messages.dismissNotice ?? en.dismissNotice)(n.message, dismiss), onClick: () => onDismiss(n.id), children: dismiss })] }) }, n.id)), _jsx("span", { className: 'hig-sr-only', role: announcement.severity === 'error' ? 'alert' : 'status', "aria-atomic": 'true', children: announcement.message })] });
38
+ return _jsxs("aside", { className: 'hig-toast', "aria-label": messages.notifications ?? en.notifications, children: [unique.map(n => _jsx(ToastNotice, { message: n.message, severity: n.severity, action: n.action, dismissName: (messages.dismissNotice ?? en.dismissNotice)(n.message, dismiss), onDismiss: () => onDismiss(n.id) }, n.id)), _jsx("span", { className: 'hig-sr-only', role: announcement.severity === 'error' ? 'alert' : 'status', "aria-atomic": 'true', children: announcement.message })] });
37
39
  }
38
40
  export function Progress({ label, value, max = 100 }) { return _jsxs("label", { className: 'hig-progress', children: [label, _jsx("progress", { "aria-label": label, value: value, max: max })] }); }
39
41
  export function Spinner({ label }) { const { messages } = useHIG(); return _jsxs("span", { className: 'hig-spinner', role: 'status', children: [_jsx("span", { className: 'hig-spinner-indicator', "aria-hidden": 'true' }), label ?? messages.loading ?? en.loading, "\u2026"] }); }
40
42
  export function Skeleton({ label }) { const { messages } = useHIG(); return _jsx("div", { className: 'hig-skeleton', "aria-label": label ?? messages.loadingContent ?? en.loadingContent, role: 'status' }); }
41
- export function EmptyState({ title, description, action }) { return _jsxs("section", { className: 'hig-surface hig-empty-state', children: [_jsx("h3", { children: title }), _jsx("p", { children: description }), action] }); }
43
+ const emptySymbol = _jsxs("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 32 32', children: [_jsx("path", { d: 'M5 18.5 8.6 8.9A2 2 0 0 1 10.5 7.5h11a2 2 0 0 1 1.9 1.4L27 18.5v4a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2Z' }), _jsx("path", { d: 'M5 18.5h6.5a4.5 4.5 0 0 0 9 0H27' })] });
44
+ /** Centred stack: symbol, title, optional description, optional action. Decorative `illustration` replaces the default symbol (same prop as native); `null` omits it. */
45
+ export function EmptyState({ title, description, action, illustration }) { return _jsxs("section", { className: 'hig-surface hig-empty-state', children: [illustration !== null && _jsx("span", { className: 'hig-empty-state-icon', "aria-hidden": 'true', children: illustration ?? emptySymbol }), _jsx("h3", { children: title }), description && _jsx("p", { children: description }), action] }); }
42
46
  export function Avatar({ name, src }) { return src ? _jsx("img", { className: 'hig-avatar', alt: name, src: src }) : _jsx("span", { className: 'hig-avatar', role: 'img', "aria-label": name, children: name.slice(0, 2) }); }
43
47
  export function StatusIndicator({ label, state }) { const { messages } = useHIG(); const text = { online: messages.statusOnline ?? en.statusOnline, offline: messages.statusOffline ?? en.statusOffline, stale: messages.statusStale ?? en.statusStale }[state] ?? state; return _jsxs("span", { className: 'hig-status-indicator', "data-state": state, children: [label, ": ", text] }); }