@bloxwap/hig 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/chart/README.md +1 -1
- package/contracts/README.md +1 -1
- package/contracts/dist/messages.d.ts +31 -4
- package/contracts/dist/messages.js +11 -2
- package/feedback/README.md +1 -1
- package/native/README.md +1 -1
- package/native/dist/account-block.d.ts +46 -0
- package/native/dist/account-block.js +28 -0
- package/native/dist/asset-balance-row.d.ts +20 -0
- package/native/dist/asset-balance-row.js +21 -0
- package/native/dist/bar-mark.d.ts +45 -0
- package/native/dist/bar-mark.js +34 -0
- package/native/dist/bar-pnl.d.ts +50 -0
- package/native/dist/bar-pnl.js +59 -0
- package/native/dist/blocks.d.ts +44 -0
- package/native/dist/{recipes.js → blocks.js} +20 -9
- package/native/dist/field.d.ts +0 -1
- package/native/dist/field.js +0 -1
- package/native/dist/icons.d.ts +8 -0
- package/native/dist/icons.js +4 -0
- package/native/dist/language-block.d.ts +31 -0
- package/native/dist/language-block.js +30 -0
- package/native/dist/list-group.d.ts +26 -0
- package/native/dist/list-group.js +27 -0
- package/native/dist/manage-position-block.d.ts +69 -0
- package/native/dist/manage-position-block.js +57 -0
- package/native/dist/notifications-block.d.ts +25 -0
- package/native/dist/notifications-block.js +14 -0
- package/native/dist/pickers.d.ts +13 -5
- package/native/dist/pickers.js +10 -6
- package/native/dist/position-block.d.ts +51 -0
- package/native/dist/position-block.js +21 -0
- package/native/dist/profile-block.d.ts +42 -0
- package/native/dist/profile-block.js +28 -0
- package/native/dist/reward-block.d.ts +83 -0
- package/native/dist/reward-block.js +35 -0
- package/native/dist/setting-header.d.ts +8 -0
- package/native/dist/setting-header.js +11 -0
- package/native/dist/setting-switch.d.ts +18 -0
- package/native/dist/setting-switch.js +17 -0
- package/native/dist/signals-block.d.ts +37 -0
- package/native/dist/signals-block.js +16 -0
- package/native/dist/sound-haptics-block.d.ts +39 -0
- package/native/dist/sound-haptics-block.js +21 -0
- package/native/dist/{swap-panel.d.ts → swap-panel-block.d.ts} +28 -9
- package/native/dist/{swap-panel.js → swap-panel-block.js} +24 -14
- package/native/dist/swap-parts.d.ts +14 -3
- package/native/dist/swap-parts.js +16 -1
- package/native/dist/swap-shared.d.ts +18 -6
- package/native/dist/swap-shared.js +3 -2
- package/native/dist/swap-sheet.d.ts +4 -4
- package/native/dist/swap-sheet.js +4 -4
- package/native/dist/swap-views.d.ts +1 -1
- package/native/dist/swap-views.js +11 -8
- package/native/dist/target-block.d.ts +83 -0
- package/native/dist/target-block.js +61 -0
- package/native/dist/token-action-block.d.ts +39 -0
- package/native/dist/token-action-block.js +20 -0
- package/native/dist/trade-history-detail-block.d.ts +59 -0
- package/native/dist/trade-history-detail-block.js +38 -0
- package/native/dist/trade-history-list-block.d.ts +44 -0
- package/native/dist/trade-history-list-block.js +29 -0
- package/native-fonts/README.md +1 -1
- package/og-fonts/README.md +1 -1
- package/package.json +246 -41
- package/react/README.md +1 -1
- package/react/dist/asset-balance-row.d.ts +19 -0
- package/react/dist/asset-balance-row.js +10 -0
- package/react/dist/bar-mark.d.ts +35 -0
- package/react/dist/bar-mark.js +21 -0
- package/react/dist/bar-pnl.d.ts +49 -0
- package/react/dist/bar-pnl.js +45 -0
- package/react/dist/blocks/account-block.d.ts +46 -0
- package/react/dist/blocks/account-block.js +27 -0
- package/react/dist/blocks/language-block.d.ts +32 -0
- package/react/dist/blocks/language-block.js +51 -0
- package/react/dist/blocks/manage-position-block.d.ts +67 -0
- package/react/dist/blocks/manage-position-block.js +28 -0
- package/react/dist/blocks/notifications-block.d.ts +23 -0
- package/react/dist/blocks/notifications-block.js +8 -0
- package/react/dist/{recipes → blocks}/pickers.d.ts +12 -4
- package/react/dist/{recipes → blocks}/pickers.js +9 -6
- package/react/dist/blocks/position-block.d.ts +49 -0
- package/react/dist/blocks/position-block.js +14 -0
- package/react/dist/blocks/profile-block.d.ts +48 -0
- package/react/dist/blocks/profile-block.js +15 -0
- package/react/dist/blocks/reward-block.d.ts +81 -0
- package/react/dist/blocks/reward-block.js +24 -0
- package/react/dist/blocks/screen-header.d.ts +9 -0
- package/react/dist/blocks/screen-header.js +12 -0
- package/react/dist/blocks/setting-switch.d.ts +10 -0
- package/react/dist/blocks/setting-switch.js +8 -0
- package/react/dist/blocks/signals-block.d.ts +35 -0
- package/react/dist/blocks/signals-block.js +15 -0
- package/react/dist/blocks/sound-haptics-block.d.ts +37 -0
- package/react/dist/blocks/sound-haptics-block.js +18 -0
- package/react/dist/{recipes → blocks}/swap/picker.d.ts +1 -1
- package/react/dist/{recipes → blocks}/swap/picker.js +4 -4
- package/react/dist/{recipes → blocks}/swap/settings.js +5 -7
- package/react/dist/{recipes → blocks}/swap/shared.d.ts +44 -6
- package/react/dist/{recipes → blocks}/swap/shared.js +25 -5
- package/react/dist/{recipes/swap-panel.d.ts → blocks/swap-panel-block.d.ts} +29 -9
- package/react/dist/{recipes/swap-panel.js → blocks/swap-panel-block.js} +22 -14
- package/react/dist/{recipes → blocks}/swap-sheet.d.ts +4 -4
- package/react/dist/{recipes → blocks}/swap-sheet.js +4 -4
- package/react/dist/blocks/target-block.d.ts +81 -0
- package/react/dist/blocks/target-block.js +65 -0
- package/react/dist/blocks/token-action-block.d.ts +37 -0
- package/react/dist/blocks/token-action-block.js +18 -0
- package/react/dist/{recipes → blocks}/trade-entry.js +2 -2
- package/react/dist/blocks/trade-history-detail-block.d.ts +58 -0
- package/react/dist/blocks/trade-history-detail-block.js +16 -0
- package/react/dist/blocks/trade-history-list-block.d.ts +43 -0
- package/react/dist/blocks/trade-history-list-block.js +21 -0
- package/react/dist/blocks.d.ts +20 -0
- package/react/dist/blocks.js +21 -0
- package/react/dist/field.d.ts +0 -2
- package/react/dist/field.js +0 -2
- package/react/dist/list-group.d.ts +26 -0
- package/react/dist/list-group.js +20 -0
- package/react/dist/styles.css +275 -8
- package/tokens/README.md +1 -1
- package/native/dist/recipes.d.ts +0 -45
- package/react/dist/recipes/activity-list.d.ts +0 -8
- package/react/dist/recipes/activity-list.js +0 -6
- package/react/dist/recipes/balance-card.d.ts +0 -6
- package/react/dist/recipes/balance-card.js +0 -5
- package/react/dist/recipes/code-window.d.ts +0 -4
- package/react/dist/recipes/code-window.js +0 -4
- package/react/dist/recipes.d.ts +0 -10
- package/react/dist/recipes.js +0 -11
- /package/react/dist/{recipes → blocks}/install-command.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/install-command.js +0 -0
- /package/react/dist/{recipes → blocks}/market-row.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/market-row.js +0 -0
- /package/react/dist/{recipes → blocks}/marketing-hero.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/marketing-hero.js +0 -0
- /package/react/dist/{recipes → blocks}/swap/amount-card.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/swap/amount-card.js +0 -0
- /package/react/dist/{recipes → blocks}/swap/settings.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/trade-entry.d.ts +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
-
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
5
4
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
6
5
|
import { useControllable, useHIG } from '../provider.js';
|
|
7
6
|
import { Button, IconButton } from '../button.js';
|
|
@@ -10,10 +9,10 @@ import { notify } from '../notify.js';
|
|
|
10
9
|
import { VerticalAddress } from '../data.js';
|
|
11
10
|
import { SwapPicker } from './swap/picker.js';
|
|
12
11
|
import { SwapSettings } from './swap/settings.js';
|
|
13
|
-
import { SwapIcon, SwapKeypad, SwapPill, addressGradient, applyAmountKey, chainsOf,
|
|
12
|
+
import { SwapIcon, SwapKeypad, SwapNumber, SwapPill, percentNumber, swapArt, swapFigure, usdNumber, addressGradient, applyAmountKey, chainsOf, parentView, sanitizeAmount, shortAddress, swapAction, testAmount, trimNumber, unitsToEntry } from './swap/shared.js';
|
|
14
13
|
export { swapAction } from './swap/shared.js';
|
|
15
14
|
export { SwapAmountCard } from './swap/amount-card.js';
|
|
16
|
-
export { SwapPill, SwapKeypad } from './swap/shared.js';
|
|
15
|
+
export { SwapPill, SwapKeypad, SwapNumber } from './swap/shared.js';
|
|
17
16
|
const textTarget = (target) => { const element = target; return !!element && (/^(INPUT|TEXTAREA|SELECT)$/.test(element.tagName) || element.isContentEditable); };
|
|
18
17
|
const amountKey = (event) => event.metaKey || event.ctrlKey || event.altKey ? null : /^[0-9.]$/.test(event.key) ? event.key : event.key === 'Backspace' ? 'back' : null;
|
|
19
18
|
/**
|
|
@@ -21,8 +20,8 @@ const amountKey = (event) => event.metaKey || event.ctrlKey || event.altKey ? nu
|
|
|
21
20
|
* or token units, token pickers, settings, and one action that names itself from the chosen pair.
|
|
22
21
|
* Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
|
|
23
22
|
*/
|
|
24
|
-
export function
|
|
25
|
-
const { messages
|
|
23
|
+
export function SwapPanelBlock({ 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, actionDisabled = false, actionStatus, actionIntent = 'primary', limitToBalance = false, banner, footer, oneWay: oneWayProp = false, denominationSwitch = true, keypad = 'auto', shortcuts = true, captureKeyboard = false, view: viewProp, onViewChange, settings, className, style }) {
|
|
24
|
+
const { messages } = useHIG();
|
|
26
25
|
const [from, setFrom] = useControllable(fromProp, defaultFrom, onFromChange);
|
|
27
26
|
const [to, setTo] = useControllable(toProp, defaultTo, onToChange);
|
|
28
27
|
const [defaultMode, setDefaultMode] = useControllable(denomination, 'usd', onDenominationChange);
|
|
@@ -71,15 +70,21 @@ export function SwapPanel({ tokens, fromTokens, fromTokensLoading, chains, hotTo
|
|
|
71
70
|
// A destination or a details card stands in for the To token: one way, and ready from the From side alone.
|
|
72
71
|
const fixed = !!destination || (!!details && !to);
|
|
73
72
|
const oneWay = oneWayProp || fixed;
|
|
74
|
-
const
|
|
75
|
-
const
|
|
73
|
+
const eligible = !!from && (!!to || fixed) && !destination?.pending && units > 0 && !insufficient;
|
|
74
|
+
const ready = eligible && !actionDisabled;
|
|
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) : actionDisabled && actionStatus ? actionStatus : actionLabel ?? (action === 'swap' && !fixed ? messages.swapActionSwap ?? en.swapActionSwap : action === 'bridge' && !fixed ? messages.swapActionBridge ?? en.swapActionBridge : messages.swapActionSend ?? en.swapActionSend);
|
|
76
76
|
const pristine = (lockFrom || !from) && (lockTo || !to) && input === 0;
|
|
77
77
|
// Updater form: several keys can land before the next render, and each must build on the last.
|
|
78
78
|
const latest = useRef(fromMode);
|
|
79
79
|
latest.current = fromMode;
|
|
80
80
|
const latestView = useRef(view);
|
|
81
81
|
latestView.current = view;
|
|
82
|
-
|
|
82
|
+
// Read at key time: several keys can land in one render.
|
|
83
|
+
const limits = useRef({ decimals: from?.decimals, balance: from?.balance ?? 0, price: fromPrice, cap: limitToBalance });
|
|
84
|
+
limits.current = { decimals: from?.decimals, balance: from?.balance ?? 0, price: fromPrice, cap: limitToBalance };
|
|
85
|
+
const over = (next) => { const { balance, price, cap } = limits.current; if (!cap || !(balance > 0))
|
|
86
|
+
return false; const value = Number(next) || 0; return (latest.current === 'token' ? value : price > 0 ? value / price : 0) > balance; };
|
|
87
|
+
const press = (key) => setEntry(current => { const next = applyAmountKey(current, key, latest.current, limits.current.decimals); return key !== 'back' && over(next) ? current : next; });
|
|
83
88
|
const paste = (text) => { const clean = text.trim().replace(/,/g, ''); if (clean === '' || !/^[0-9]*\.?[0-9]*$/.test(clean))
|
|
84
89
|
return false; const next = sanitizeAmount(clean); setEntry(latest.current === 'usd' ? trimNumber(Number(next) || 0, 2) : next); return true; };
|
|
85
90
|
const switchFromMode = (mode) => { if (mode === fromMode)
|
|
@@ -146,12 +151,13 @@ export function SwapPanel({ tokens, fromTokens, fromTokensLoading, chains, hotTo
|
|
|
146
151
|
const onPaste = (event) => { if (!captureKeyboard && inPanel(event) && paste(event.clipboardData.getData('text')))
|
|
147
152
|
event.preventDefault(); };
|
|
148
153
|
const chainList = useMemo(() => chains ?? chainsOf(tokens), [chains, tokens]);
|
|
149
|
-
|
|
154
|
+
// The fee keeps its sentence; only a known amount moves. Loading and unknown are plain placeholders.
|
|
155
|
+
const feeLine = quoteLoading || fee == null ? (messages.swapFee ?? en.swapFee)(quoteLoading ? '…' : '—') : _jsx(SwapNumber, { template: messages.swapFee ?? en.swapFee, ...usdNumber(fee) });
|
|
150
156
|
const fraction = entry.includes('.') ? Math.min(entry.length - entry.indexOf('.') - 1, fromMode === 'usd' ? 2 : 8) : 0;
|
|
151
157
|
// 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 ?
|
|
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 &&
|
|
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
|
|
158
|
+
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 ? swapArt(token.icon) : _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: swapFigure(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) }) })] });
|
|
159
|
+
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 && swapArt(token.chainIcon), token.icon ? swapArt(token.icon) : _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) })] }), _jsx(SwapNumber, { value: token.balance, suffix: ' ' + token.symbol, options: { maximumFractionDigits: 6 } })] })
|
|
160
|
+
: _jsxs("span", { className: 'hig-swap-meta', children: [_jsxs(SwapPill, { onClick: () => show(onSlippageChange ? 'slippage' : 'settings'), children: [_jsx(SwapIcon, { name: 'sliders', size: 14 }), _jsx(SwapNumber, { template: messages.swapSlippage ?? en.swapSlippage, ...percentNumber(slippage) })] }), _jsx("span", { children: feeLine })] })] });
|
|
155
161
|
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
162
|
const card = (side) => {
|
|
157
163
|
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;
|
|
@@ -161,10 +167,12 @@ export function SwapPanel({ tokens, fromTokens, fromTokensLoading, chains, hotTo
|
|
|
161
167
|
!(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
168
|
};
|
|
163
169
|
// 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 ?
|
|
170
|
+
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 ? swapArt(destination.icon) : 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: swapFigure(destination.detail) }), fee !== undefined && _jsx("span", { children: feeLine })] }), 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: typeof row.value === 'number' ? _jsx(SwapNumber, { value: row.value, options: row.options, prefix: row.prefix, suffix: row.suffix }) : row.value })] }, row.label)) })] });
|
|
165
171
|
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 })
|
|
172
|
+
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 })] }), banner, 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, intent: actionIntent, 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' }) })] }), footer] }) : 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
173
|
: 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
174
|
: _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
175
|
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
176
|
}
|
|
177
|
+
/** @deprecated Renamed `SwapPanelBlock`. The old name and the `blocks/swap-panel` and `recipes/swap-panel` import paths keep working until the next major release. */
|
|
178
|
+
export const SwapPanel = SwapPanelBlock;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type
|
|
3
|
-
export interface SwapSheetProps extends
|
|
2
|
+
import { type SwapPanelBlockProps } from './swap-panel-block.js';
|
|
3
|
+
export interface SwapSheetProps extends SwapPanelBlockProps {
|
|
4
4
|
open: boolean;
|
|
5
5
|
onOpenChange: (open: boolean) => void;
|
|
6
6
|
/** Accessible name of the sheet; not drawn. */
|
|
@@ -9,8 +9,8 @@ export interface SwapSheetProps extends SwapPanelProps {
|
|
|
9
9
|
trigger?: React.ReactNode;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* SwapPanelBlock presented in a gesture sheet (Vaul). Token pickers and settings push inside the same sheet, which resizes to
|
|
13
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
|
|
14
|
+
* Lives in its own entry so the blocks aggregate stays free of the optional Vaul peer.
|
|
15
15
|
*/
|
|
16
16
|
export declare function SwapSheet({ open, onOpenChange, title, trigger, view: viewProp, onViewChange, ...panel }: SwapSheetProps): React.JSX.Element;
|
|
@@ -3,12 +3,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
4
|
import { useControllable } from '../provider.js';
|
|
5
5
|
import { GestureSheet } from '../gesture-sheet.js';
|
|
6
|
-
import {
|
|
6
|
+
import { SwapPanelBlock } from './swap-panel-block.js';
|
|
7
7
|
import { parentView } from './swap/shared.js';
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* SwapPanelBlock presented in a gesture sheet (Vaul). Token pickers and settings push inside the same sheet, which resizes to
|
|
10
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
|
|
11
|
+
* Lives in its own entry so the blocks aggregate stays free of the optional Vaul peer.
|
|
12
12
|
*/
|
|
13
13
|
export function SwapSheet({ open, onOpenChange, title, trigger, view: viewProp, onViewChange, ...panel }) {
|
|
14
14
|
const [view, show] = useControllable(viewProp, 'main', onViewChange);
|
|
@@ -18,5 +18,5 @@ export function SwapSheet({ open, onOpenChange, title, trigger, view: viewProp,
|
|
|
18
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
19
|
event.preventDefault();
|
|
20
20
|
show(parentView(view));
|
|
21
|
-
} } }, children: _jsx(
|
|
21
|
+
} } }, children: _jsx(SwapPanelBlock, { ...panel, view: view, onViewChange: show }) });
|
|
22
22
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** What the target does: close in profit, or cap the loss. */
|
|
3
|
+
export type TargetKind = 'take-profit' | 'stop-loss';
|
|
4
|
+
/** How the target is expressed: profit or loss in dollars, a price, or a share of the position. */
|
|
5
|
+
export type TargetUnit = 'dollar' | 'price' | 'percent';
|
|
6
|
+
/** The three prices on the bar. */
|
|
7
|
+
export type TargetPrice = 'entry' | 'trigger';
|
|
8
|
+
/** The words of the block. They are trading terms, so the host supplies them in its own vocabulary and language; only Cancel has a built-in default. */
|
|
9
|
+
export interface TargetBlockLabels {
|
|
10
|
+
/** Heading: Take Profit, Stop Loss. */
|
|
11
|
+
title: string;
|
|
12
|
+
/** The confirming action: Set Take Profit. */
|
|
13
|
+
submit: string;
|
|
14
|
+
/** Defaults to the built-in Cancel. */
|
|
15
|
+
cancel?: string;
|
|
16
|
+
entry: string;
|
|
17
|
+
/** The price the order triggers at: If triggered. */
|
|
18
|
+
trigger: string;
|
|
19
|
+
/** Accessible name of the unit control; not drawn. */
|
|
20
|
+
unit: string;
|
|
21
|
+
units: Record<TargetUnit, string>;
|
|
22
|
+
/** The row that opens the host's own entry: Custom. */
|
|
23
|
+
custom: string;
|
|
24
|
+
/** Accessible name of the info button that shows `note`: How this order fills. Without it the note is always shown. */
|
|
25
|
+
info?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface TargetBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
|
|
28
|
+
kind: TargetKind;
|
|
29
|
+
labels: TargetBlockLabels;
|
|
30
|
+
/** Title of the price card, the position the target belongs to: `BTC · Long 40×`. */
|
|
31
|
+
position?: string;
|
|
32
|
+
/** Trailing text of the price card, the order the target places: Take-limit, Stop-market. */
|
|
33
|
+
orderType?: string;
|
|
34
|
+
/** One sentence about how the order fills. With `labels.info` it opens in a popover from an info button on the trailing edge of the header; otherwise it is always shown under the headline figure. */
|
|
35
|
+
note?: string;
|
|
36
|
+
entry: number;
|
|
37
|
+
/** Price the order triggers at. Defaults to `value` when the unit is `price`; otherwise unknown until the host supplies it. */
|
|
38
|
+
trigger?: number | null;
|
|
39
|
+
unit: TargetUnit;
|
|
40
|
+
/** Units offered, in order. Defaults to all three; one unit hides the control. */
|
|
41
|
+
units?: readonly TargetUnit[];
|
|
42
|
+
onUnitChange?: (unit: TargetUnit) => void;
|
|
43
|
+
/** The target in the current unit: signed dollars (2, -0.5), a price, or a signed fraction (0.05 reads +5%). `null` reads as unknown and disables the confirming action. */
|
|
44
|
+
value: number | null;
|
|
45
|
+
onValueChange?: (value: number) => void;
|
|
46
|
+
/** Quick choices in the current unit. The one equal to `value` is shown selected. */
|
|
47
|
+
presets?: readonly number[];
|
|
48
|
+
/** Shows the Custom row; the host opens its own entry. */
|
|
49
|
+
onCustom?: () => void;
|
|
50
|
+
/** Format of prices. Defaults to US dollars. */
|
|
51
|
+
priceOptions?: Intl.NumberFormatOptions;
|
|
52
|
+
/** Set true to draw the prices inside a card: a surface fill, padding and radius. By default the title row, bar and readouts sit directly on the screen. */
|
|
53
|
+
surface?: boolean;
|
|
54
|
+
onSubmit: () => void;
|
|
55
|
+
/** Defaults to disabled while `value` is unknown. */
|
|
56
|
+
submitDisabled?: boolean;
|
|
57
|
+
busy?: boolean;
|
|
58
|
+
/** Shows Cancel beside the confirming action. */
|
|
59
|
+
onCancel?: () => void;
|
|
60
|
+
onBack?: () => void;
|
|
61
|
+
/** A control on the trailing edge of the header, usually an `IconButton`. It takes the place of the info button, and the note is then always shown. */
|
|
62
|
+
headerAction?: React.ReactNode;
|
|
63
|
+
}
|
|
64
|
+
/** Number format of a target in a unit. Dollars and percents carry their sign; `short` drops the cents of a whole dollar amount, for a preset. */
|
|
65
|
+
export declare function targetFormat(unit: TargetUnit, priceOptions?: Intl.NumberFormatOptions, short?: number): Intl.NumberFormatOptions;
|
|
66
|
+
/**
|
|
67
|
+
* Where each known price sits on the bar, as a fraction of its width from the low-price edge, the prices in price order, and
|
|
68
|
+
* the stretch (`from` to `to`) between them: the whole bar, from entry to the trigger.
|
|
69
|
+
* Without a trigger there is no stretch.
|
|
70
|
+
*/
|
|
71
|
+
export declare function targetLayout({ entry, trigger }: {
|
|
72
|
+
entry: number;
|
|
73
|
+
trigger?: number | null;
|
|
74
|
+
}): {
|
|
75
|
+
positions: Partial<Record<TargetPrice, number>>;
|
|
76
|
+
order: TargetPrice[];
|
|
77
|
+
from: number;
|
|
78
|
+
to: number;
|
|
79
|
+
};
|
|
80
|
+
/** Set a take profit or a stop loss on one position: the target as the headline figure, a price card whose bar shows how far the price is from the trigger, the unit, the host's quick choices, and the confirming action. */
|
|
81
|
+
export declare function TargetBlock({ kind, labels, position, orderType, note, entry, trigger, unit, units, onUnitChange, value, onValueChange, presets, onCustom, priceOptions, surface, onSubmit, submitDisabled, busy, onCancel, onBack, headerAction, className, ...rest }: TargetBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useRef, useState } from 'react';
|
|
4
|
+
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
5
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
6
|
+
import { useHIG } from '../provider.js';
|
|
7
|
+
import { Button } from '../button.js';
|
|
8
|
+
import { SegmentedControl } from '../selection.js';
|
|
9
|
+
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
10
|
+
import { ScreenHeader } from './screen-header.js';
|
|
11
|
+
import { SwapIcon } from './swap/shared.js';
|
|
12
|
+
const usd = { style: 'currency', currency: 'USD' }, allUnits = ['dollar', 'price', 'percent'];
|
|
13
|
+
const known = (value) => value != null && Number.isFinite(value);
|
|
14
|
+
/** Number format of a target in a unit. Dollars and percents carry their sign; `short` drops the cents of a whole dollar amount, for a preset. */
|
|
15
|
+
export function targetFormat(unit, priceOptions = usd, short) {
|
|
16
|
+
if (unit === 'price')
|
|
17
|
+
return priceOptions;
|
|
18
|
+
if (unit === 'percent')
|
|
19
|
+
return { style: 'percent', maximumFractionDigits: 2, signDisplay: 'exceptZero' };
|
|
20
|
+
return { ...usd, signDisplay: 'exceptZero', ...(short !== undefined && Number.isInteger(short) ? { maximumFractionDigits: 0 } : null) };
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Where each known price sits on the bar, as a fraction of its width from the low-price edge, the prices in price order, and
|
|
24
|
+
* the stretch (`from` to `to`) between them: the whole bar, from entry to the trigger.
|
|
25
|
+
* Without a trigger there is no stretch.
|
|
26
|
+
*/
|
|
27
|
+
export function targetLayout({ entry, trigger }) {
|
|
28
|
+
const values = {};
|
|
29
|
+
if (known(entry))
|
|
30
|
+
values.entry = entry;
|
|
31
|
+
if (known(trigger))
|
|
32
|
+
values.trigger = trigger;
|
|
33
|
+
const kinds = Object.keys(values), prices = kinds.map(kind => values[kind]);
|
|
34
|
+
if (!kinds.length)
|
|
35
|
+
return { positions: {}, order: [], from: 0.5, to: 0.5 };
|
|
36
|
+
const low = Math.min(...prices), span = Math.max(...prices) - low;
|
|
37
|
+
const positions = {};
|
|
38
|
+
for (const kind of kinds)
|
|
39
|
+
positions[kind] = span > 0 ? (values[kind] - low) / span : 0.5;
|
|
40
|
+
const rank = { entry: 0, trigger: 1 };
|
|
41
|
+
const order = [...kinds].sort((a, b) => values[a] - values[b] || rank[a] - rank[b]);
|
|
42
|
+
const start = positions.entry, end = positions.trigger;
|
|
43
|
+
return start === undefined || end === undefined ? { positions, order, from: 0.5, to: 0.5 } : { positions, order, from: Math.min(start, end), to: Math.max(start, end) };
|
|
44
|
+
}
|
|
45
|
+
/** Set a take profit or a stop loss on one position: the target as the headline figure, a price card whose bar shows how far the price is from the trigger, the unit, the host's quick choices, and the confirming action. */
|
|
46
|
+
export function TargetBlock({ kind, labels, position, orderType, note, entry, trigger, unit, units = allUnits, onUnitChange, value, onValueChange, presets = [], onCustom, priceOptions = usd, surface = false, onSubmit, submitDisabled, busy, onCancel, onBack, headerAction, className, ...rest }) {
|
|
47
|
+
const { messages, locale } = useHIG();
|
|
48
|
+
const id = useId(), noteId = useId();
|
|
49
|
+
const [open, setOpen] = useState(false);
|
|
50
|
+
const anchor = useRef(null);
|
|
51
|
+
// The popover closes on a press outside it, on Escape, and when focus leaves it.
|
|
52
|
+
useEffect(() => { if (!open)
|
|
53
|
+
return; const outside = (event) => { if (!anchor.current?.contains(event.target))
|
|
54
|
+
setOpen(false); }; document.addEventListener('pointerdown', outside); return () => document.removeEventListener('pointerdown', outside); }, [open]);
|
|
55
|
+
const info = note && labels.info && !headerAction ? labels.info : undefined;
|
|
56
|
+
const target = trigger !== undefined ? trigger : unit === 'price' ? value : null;
|
|
57
|
+
const { positions, order, from, to } = targetLayout({ entry, trigger: target });
|
|
58
|
+
const prices = { entry, trigger: target };
|
|
59
|
+
const intent = kind === 'stop-loss' ? 'destructive' : 'primary';
|
|
60
|
+
return _jsxs("section", { ...rest, className: `hig-target-block${className ? ` ${className}` : ''}`, "data-kind": kind, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: info ? _jsxs("span", { ref: anchor, className: 'hig-target-info', onKeyDown: event => { if (event.key === 'Escape' && open) {
|
|
61
|
+
event.stopPropagation();
|
|
62
|
+
setOpen(false);
|
|
63
|
+
} }, onBlur: event => { if (!event.currentTarget.contains(event.relatedTarget))
|
|
64
|
+
setOpen(false); }, children: [_jsx("button", { type: 'button', className: 'hig-swap-back', "aria-label": info, "aria-expanded": open, "aria-controls": open ? noteId : undefined, onClick: () => setOpen(!open), children: _jsx(SwapIcon, { name: 'info' }) }), open && _jsx("span", { id: noteId, role: 'status', className: 'hig-popover hig-target-popover', children: note })] }) : headerAction }), _jsx("p", { className: 'hig-target-amount', children: _jsx(AnimatedNumberReadout, { value: value, options: targetFormat(unit, priceOptions) }) }), note && !info && _jsx("p", { className: 'hig-target-note', children: note }), _jsxs("section", { className: surface ? 'hig-surface hig-target-prices' : 'hig-target-prices', "data-surface": surface ? undefined : 'false', "aria-labelledby": position ? id : undefined, children: [(position || orderType) && _jsxs("div", { className: 'hig-bar-mark-header', children: [position && _jsx("strong", { id: id, className: 'hig-bar-mark-title', children: position }), orderType && _jsx("span", { className: 'hig-bar-mark-description', children: orderType })] }), _jsxs("div", { className: 'hig-target-bar', "aria-hidden": 'true', children: [_jsx("span", { className: 'hig-target-rest', style: { flexGrow: from } }), to > from && _jsx("span", { className: 'hig-target-move', "data-lead": (positions.trigger ?? 0) < (positions.entry ?? 0) ? 'trigger' : 'start', style: { flexGrow: to - from } }), _jsx("span", { className: 'hig-target-rest', style: { flexGrow: 1 - to } })] }), _jsx("dl", { className: 'hig-bar-pnl-readouts', children: order.map(price => _jsxs("div", { "data-price": price, children: [_jsx("dt", { children: labels[price] }), _jsx("dd", { children: _jsx(AnimatedNumberReadout, { value: prices[price], options: priceOptions }) })] }, price)) })] }), units.length > 1 && _jsx(SegmentedControl, { label: labels.unit, options: units.map(option => ({ value: option, label: labels.units[option] })), value: unit, onValueChange: next => onUnitChange?.(next) }), onCustom && _jsxs("button", { type: 'button', className: 'hig-swap-setting', onClick: onCustom, children: [_jsx("span", { children: labels.custom }), _jsx(SwapIcon, { name: 'chevron', size: 16 })] }), presets.length > 0 && _jsx("div", { className: 'hig-target-presets', children: presets.map(preset => _jsx(Button, { fullWidth: true, intent: preset === value ? intent : 'secondary', "aria-pressed": preset === value, onClick: () => onValueChange?.(preset), children: formatNumber(preset, locale, targetFormat(unit, priceOptions, preset)) }, preset)) }), _jsxs("div", { className: 'hig-target-actions', children: [onCancel && _jsx(Button, { fullWidth: true, intent: 'secondary', onClick: onCancel, children: labels.cancel ?? messages.cancel ?? en.cancel }), _jsx(Button, { fullWidth: true, intent: intent, disabled: submitDisabled ?? value === null, busy: busy, onClick: onSubmit, children: labels.submit })] })] });
|
|
65
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { HIGMessages } from '@bloxwap/hig/contracts/messages';
|
|
3
|
+
import { type BarMarkElement } from '../bar-mark.js';
|
|
4
|
+
export type { BarMarkElement, BarMarkTone } from '../bar-mark.js';
|
|
5
|
+
/** Actions with a built-in, translated label. */
|
|
6
|
+
export type TokenActionId = 'send' | 'receive' | 'stake' | 'unstake';
|
|
7
|
+
export interface TokenAction {
|
|
8
|
+
/** `send`, `receive`, `stake` and `unstake` take a built-in label; any other id needs `label`. */
|
|
9
|
+
id: TokenActionId | (string & {});
|
|
10
|
+
label?: string;
|
|
11
|
+
onSelect: () => void;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Defaults to `secondary`: the card offers equal choices, so no action is the primary one unless the host says so. */
|
|
14
|
+
intent?: 'primary' | 'secondary' | 'destructive';
|
|
15
|
+
}
|
|
16
|
+
export interface TokenActionBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
|
|
17
|
+
/** Heading, usually the ticker: HYPE. */
|
|
18
|
+
symbol: string;
|
|
19
|
+
/** Title of the assets bar: Hyperliquid. */
|
|
20
|
+
name: string;
|
|
21
|
+
/** Total holding in dollars, on the trailing edge of the assets bar. Defaults to the sum of the asset values; `null` reads as unknown. */
|
|
22
|
+
value?: number | null;
|
|
23
|
+
/** Where the token is held: Staked, Core, Paper. */
|
|
24
|
+
assets: readonly BarMarkElement[];
|
|
25
|
+
/** The chains the token sits on. */
|
|
26
|
+
chains: readonly BarMarkElement[];
|
|
27
|
+
/** Title of the chains bar. Defaults to the built-in “Chains”. */
|
|
28
|
+
chainsTitle?: string;
|
|
29
|
+
actions: readonly TokenAction[];
|
|
30
|
+
onBack?: () => void;
|
|
31
|
+
/** A control on the trailing edge of the header, usually an `IconButton`. */
|
|
32
|
+
headerAction?: React.ReactNode;
|
|
33
|
+
}
|
|
34
|
+
/** The text of an action: its `label`, the built-in label for a known id, or the id itself. */
|
|
35
|
+
export declare const tokenActionLabel: (action: TokenAction, messages?: Partial<HIGMessages>) => string;
|
|
36
|
+
/** One token and what can be done with it: where it is held, which chains it sits on, and the actions as equal full-width buttons. */
|
|
37
|
+
export declare function TokenActionBlock({ symbol, name, value, assets, chains, chainsTitle, actions, onBack, headerAction, className, ...rest }: TokenActionBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
4
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
|
+
import { useHIG } from '../provider.js';
|
|
6
|
+
import { Button } from '../button.js';
|
|
7
|
+
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
8
|
+
import { BarMark } from '../bar-mark.js';
|
|
9
|
+
import { ScreenHeader } from './screen-header.js';
|
|
10
|
+
const usd = { style: 'currency', currency: 'USD' }, held = (value) => Number.isFinite(value) && value > 0;
|
|
11
|
+
/** The text of an action: its `label`, the built-in label for a known id, or the id itself. */
|
|
12
|
+
export const tokenActionLabel = (action, messages = {}) => action.label ?? (action.id === 'send' ? messages.swapActionSend ?? en.swapActionSend : action.id === 'receive' ? messages.receive ?? en.receive : action.id === 'stake' ? messages.stake ?? en.stake : action.id === 'unstake' ? messages.unstake ?? en.unstake : action.id);
|
|
13
|
+
/** One token and what can be done with it: where it is held, which chains it sits on, and the actions as equal full-width buttons. */
|
|
14
|
+
export function TokenActionBlock({ symbol, name, value, assets, chains, chainsTitle, actions, onBack, headerAction, className, ...rest }) {
|
|
15
|
+
const { messages, locale } = useHIG();
|
|
16
|
+
const total = value !== undefined ? value : assets.reduce((sum, asset) => sum + (held(asset.value) ? asset.value : 0), 0);
|
|
17
|
+
return _jsxs("section", { ...rest, className: `hig-token-card${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: symbol, onBack: onBack, action: headerAction }), _jsxs("div", { className: 'hig-token-bars', children: [_jsx(BarMark, { surface: false, title: name, description: _jsx(AnimatedNumberReadout, { value: total, options: usd }), elements: assets }), _jsx(BarMark, { surface: false, title: chainsTitle ?? messages.swapChains ?? en.swapChains, description: formatNumber(chains.filter(chain => held(chain.value)).length, locale), elements: chains })] }), actions.length > 0 && _jsx("div", { className: 'hig-token-actions', children: actions.map(action => _jsx(Button, { fullWidth: true, intent: action.intent ?? 'secondary', disabled: action.disabled, onClick: action.onSelect, children: tokenActionLabel(action, messages) }, action.id)) })] });
|
|
18
|
+
}
|
|
@@ -5,8 +5,8 @@ import * as en from '@bloxwap/hig/contracts/messages';
|
|
|
5
5
|
import { useHIG } from '../provider.js';
|
|
6
6
|
import { Button } from '../button.js';
|
|
7
7
|
import { Surface, Stack, Heading } from '../surface.js';
|
|
8
|
-
import { Field,
|
|
8
|
+
import { Field, Input } 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(
|
|
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(Input, { type: 'text', inputMode: 'decimal', 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 }) })] })] }) }); }
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AssetArtwork } from '../asset-balance-row.js';
|
|
3
|
+
/** The words of the card. They are trading terms, so the host supplies them; HIG ships none. */
|
|
4
|
+
export interface TradeHistoryDetailLabels {
|
|
5
|
+
title: string;
|
|
6
|
+
/** Names the figure for assistive technology: Net PnL. It is not drawn; the signed figure and the line under it carry the meaning on screen. */
|
|
7
|
+
netPnl: string;
|
|
8
|
+
/** Names of the two prices under the bar. Needed with `entry` and `exit`. */
|
|
9
|
+
entry?: string;
|
|
10
|
+
exit?: string;
|
|
11
|
+
/** `+2.84% on margin`: receives the formatted percent. */
|
|
12
|
+
onMargin: (percent: string) => string;
|
|
13
|
+
long: string;
|
|
14
|
+
short: string;
|
|
15
|
+
}
|
|
16
|
+
/** One label and value row. A number is formatted with `options` between `prefix` and `suffix`; a string is drawn as given, for example a duration the host has already formatted. */
|
|
17
|
+
export interface TradeHistoryDetail {
|
|
18
|
+
label: string;
|
|
19
|
+
value: string | number;
|
|
20
|
+
options?: Intl.NumberFormatOptions;
|
|
21
|
+
prefix?: string;
|
|
22
|
+
suffix?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface TradeHistoryAction {
|
|
25
|
+
id: string;
|
|
26
|
+
label: string;
|
|
27
|
+
onSelect: () => void;
|
|
28
|
+
intent?: 'primary' | 'secondary';
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
busy?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface TradeHistoryDetailBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
|
|
33
|
+
labels: TradeHistoryDetailLabels;
|
|
34
|
+
/** Asset name: Amazon. */
|
|
35
|
+
name: string;
|
|
36
|
+
icon?: AssetArtwork;
|
|
37
|
+
side: 'long' | 'short';
|
|
38
|
+
/** 20 reads `20×`. */
|
|
39
|
+
leverage?: number;
|
|
40
|
+
/** Net profit and loss in dollars. `null` reads as unknown. */
|
|
41
|
+
pnl: number | null;
|
|
42
|
+
/** Return on margin as a fraction: 0.0284 reads +2.84%. */
|
|
43
|
+
pnlPercent?: number | null;
|
|
44
|
+
/** Entry and exit prices. With both, one bar runs from entry to exit in the result colour, with the two prices under it, in place of two rows. */
|
|
45
|
+
entry?: number;
|
|
46
|
+
exit?: number;
|
|
47
|
+
/** Format of the two prices. Defaults to US dollars. */
|
|
48
|
+
priceOptions?: Intl.NumberFormatOptions;
|
|
49
|
+
/** The trade's other figures in the order shown: size, notional, time held, fees, funding. They are drawn as a grid of small labels over values. */
|
|
50
|
+
details: readonly TradeHistoryDetail[];
|
|
51
|
+
/** Actions in one row under the details, such as Save image and Share. */
|
|
52
|
+
actions?: readonly TradeHistoryAction[];
|
|
53
|
+
onBack?: () => void;
|
|
54
|
+
/** A control on the trailing edge of the header, usually an `IconButton`. */
|
|
55
|
+
headerAction?: React.ReactNode;
|
|
56
|
+
}
|
|
57
|
+
/** The full record of one closed trade, drawn on the screen without cards because none of it is pressable: the asset with its side and leverage on one line, the net result as the headline figure, a bar from the entry price to the exit price, the other figures as a compact grid, and the host's actions. */
|
|
58
|
+
export declare function TradeHistoryDetailBlock({ labels, name, icon, side, leverage, pnl, pnlPercent, entry, exit, priceOptions, details, actions, onBack, headerAction, className, ...rest }: TradeHistoryDetailBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
4
|
+
import { useHIG } from '../provider.js';
|
|
5
|
+
import { Button } from '../button.js';
|
|
6
|
+
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
7
|
+
import { BarPnl } from '../bar-pnl.js';
|
|
8
|
+
import { ScreenHeader } from './screen-header.js';
|
|
9
|
+
import { SwapNumber } from './swap/shared.js';
|
|
10
|
+
const pnlFormat = { style: 'currency', currency: 'USD', signDisplay: 'exceptZero', maximumFractionDigits: 4 }, percentFormat = { style: 'percent', minimumFractionDigits: 2, maximumFractionDigits: 2, signDisplay: 'exceptZero' };
|
|
11
|
+
/** The full record of one closed trade, drawn on the screen without cards because none of it is pressable: the asset with its side and leverage on one line, the net result as the headline figure, a bar from the entry price to the exit price, the other figures as a compact grid, and the host's actions. */
|
|
12
|
+
export function TradeHistoryDetailBlock({ labels, name, icon, side, leverage, pnl, pnlPercent, entry, exit, priceOptions, details, actions = [], onBack, headerAction, className, ...rest }) {
|
|
13
|
+
const { locale } = useHIG();
|
|
14
|
+
const tone = pnl == null || pnl === 0 ? undefined : pnl > 0 ? 'up' : 'down';
|
|
15
|
+
return _jsxs("section", { ...rest, className: `hig-trade-detail${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction }), _jsxs("div", { className: 'hig-trade-summary', children: [_jsxs("div", { className: 'hig-trade-result', "data-tone": tone, children: [_jsxs("div", { className: 'hig-trade-identity', children: [_jsx("span", { className: 'hig-trade-avatar', "aria-hidden": 'true', children: typeof icon === 'string' ? _jsx("img", { src: icon, alt: '' }) : icon ?? name.slice(0, 3) }), _jsx("strong", { children: name }), _jsxs("span", { children: [_jsxs("span", { className: 'hig-position-side hig-trade-side', "data-side": side, children: [_jsxs("span", { "aria-hidden": 'true', children: [side === 'long' ? '↑' : '↓', " "] }), side === 'long' ? labels.long : labels.short] }), leverage != null && _jsxs(_Fragment, { children: [" ", formatNumber(leverage, locale), "\u00D7"] })] })] }), _jsxs("strong", { className: 'hig-trade-figure', children: [_jsxs("span", { className: 'hig-trade-caption hig-sr-only', children: [labels.netPnl, " "] }), _jsx(AnimatedNumberReadout, { value: pnl, options: pnlFormat })] }), pnlPercent !== undefined && _jsx("span", { className: 'hig-trade-return', children: pnlPercent === null ? labels.onMargin('—') : _jsx(SwapNumber, { template: labels.onMargin, value: pnlPercent, options: percentFormat }) })] }), entry != null && exit != null && _jsx(BarPnl, { className: 'hig-trade-bar', surface: false, fit: true, side: side, entry: entry, mark: exit, labels: { entry: labels.entry ?? '', mark: labels.exit ?? '', liquidation: '' }, priceOptions: priceOptions }), details.length > 0 && _jsx("dl", { className: 'hig-trade-details', children: details.map(row => _jsxs("div", { children: [_jsx("dt", { children: row.label }), _jsx("dd", { children: typeof row.value === 'number' ? _jsx(SwapNumber, { value: row.value, options: row.options, prefix: row.prefix, suffix: row.suffix }) : row.value })] }, row.label)) })] }), actions.length > 0 && _jsx("div", { className: 'hig-trade-actions', children: actions.map(action => _jsx(Button, { fullWidth: true, intent: action.intent ?? 'secondary', disabled: action.disabled, busy: action.busy, onClick: action.onSelect, children: action.label }, action.id)) })] });
|
|
16
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AssetArtwork } from '../asset-balance-row.js';
|
|
3
|
+
/** The words of the card. They are trading terms, so the host supplies them; HIG ships none. */
|
|
4
|
+
export interface TradeHistoryListLabels {
|
|
5
|
+
/** Heading of the screen: History. */
|
|
6
|
+
title: string;
|
|
7
|
+
long: string;
|
|
8
|
+
short: string;
|
|
9
|
+
/** Shown in place of the rows when there are no trades. */
|
|
10
|
+
empty: string;
|
|
11
|
+
}
|
|
12
|
+
/** One closed trade. */
|
|
13
|
+
export interface TradeHistoryItem {
|
|
14
|
+
id: string;
|
|
15
|
+
/** Asset name: Amazon. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Round artwork: an image URL or a host element. Without it the row shows the first letters of the name. */
|
|
18
|
+
icon?: AssetArtwork;
|
|
19
|
+
side: 'long' | 'short';
|
|
20
|
+
/** 20 reads `20×`. */
|
|
21
|
+
leverage?: number;
|
|
22
|
+
/** Net profit and loss in dollars. `null` reads as unknown. */
|
|
23
|
+
pnl: number | null;
|
|
24
|
+
/** Host-formatted age or time of the close, shown under the result: `2d`. */
|
|
25
|
+
time?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface TradeHistoryListBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title' | 'onSelect'> {
|
|
28
|
+
labels: TradeHistoryListLabels;
|
|
29
|
+
/** Closed trades, in the order shown. The host sorts and pages them. */
|
|
30
|
+
trades: readonly TradeHistoryItem[];
|
|
31
|
+
/** Makes each row a button that reports its trade, usually to open its detail, and shows the disclosure chevron. */
|
|
32
|
+
onSelect?: (trade: TradeHistoryItem) => void;
|
|
33
|
+
/** Shows Back on the leading edge of the header. */
|
|
34
|
+
onBack?: () => void;
|
|
35
|
+
/** A control on the trailing edge of the header, usually an `IconButton`. */
|
|
36
|
+
headerAction?: React.ReactNode;
|
|
37
|
+
/** Format of the result. Defaults to signed US dollars at four significant digits: `+$1.412`, `+$17.90`, `-$0.6878`. */
|
|
38
|
+
pnlOptions?: Intl.NumberFormatOptions;
|
|
39
|
+
}
|
|
40
|
+
/** How a row reads its side: `Short 20×`, or `Short` without leverage. */
|
|
41
|
+
export declare const tradeHistorySide: (trade: Pick<TradeHistoryItem, 'side' | 'leverage'>, labels: Pick<TradeHistoryListLabels, 'long' | 'short'>, locale?: string) => string;
|
|
42
|
+
/** A history of closed trades as one screen: a header, then one row per trade with the asset, its side and leverage in the direction colour, and the net result in the result colour over its age. */
|
|
43
|
+
export declare function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions, className, ...rest }: TradeHistoryListBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
4
|
+
import { useHIG } from '../provider.js';
|
|
5
|
+
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
6
|
+
import { ScreenHeader } from './screen-header.js';
|
|
7
|
+
const pnlFormat = { style: 'currency', currency: 'USD', signDisplay: 'exceptZero', minimumSignificantDigits: 4, maximumSignificantDigits: 4 };
|
|
8
|
+
/** How a row reads its side: `Short 20×`, or `Short` without leverage. */
|
|
9
|
+
export const tradeHistorySide = (trade, labels, locale) => `${trade.side === 'long' ? labels.long : labels.short}${trade.leverage != null ? ` ${formatNumber(trade.leverage, locale)}×` : ''}`;
|
|
10
|
+
const arrow = (side) => _jsx("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 16 16', width: '16', height: '16', fill: 'none', stroke: 'currentColor', strokeWidth: '1.8', strokeLinecap: 'round', strokeLinejoin: 'round', children: side === 'long' ? _jsx("path", { d: 'M8 13V3.5M4 7.5l4-4 4 4' }) : _jsx("path", { d: 'M8 3v9.5M4 8.5l4 4 4-4' }) });
|
|
11
|
+
const chevron = _jsx("svg", { className: 'hig-trade-row-chevron', "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', width: '20', height: '20', fill: 'none', stroke: 'currentColor', strokeWidth: '1.8', strokeLinecap: 'round', strokeLinejoin: 'round', children: _jsx("path", { d: 'm7.5 4.5 5.5 5.5-5.5 5.5' }) });
|
|
12
|
+
/** A history of closed trades as one screen: a header, then one row per trade with the asset, its side and leverage in the direction colour, and the net result in the result colour over its age. */
|
|
13
|
+
export function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions = pnlFormat, className, ...rest }) {
|
|
14
|
+
const { locale } = useHIG();
|
|
15
|
+
const row = (trade) => {
|
|
16
|
+
const side = tradeHistorySide(trade, labels, locale), tone = trade.pnl == null || trade.pnl === 0 ? undefined : trade.pnl > 0 ? 'up' : 'down';
|
|
17
|
+
const content = _jsxs(_Fragment, { children: [_jsx("span", { className: 'hig-asset-row-icon', "aria-hidden": 'true', children: typeof trade.icon === 'string' ? _jsx("img", { src: trade.icon, alt: '' }) : trade.icon ?? trade.name.slice(0, 3) }), _jsxs("span", { className: 'hig-trade-row-identity', children: [_jsx("strong", { children: trade.name }), _jsxs("span", { className: 'hig-trade-row-side', "data-side": trade.side, children: [arrow(trade.side), _jsxs("span", { className: 'hig-sr-only', children: [trade.side === 'long' ? labels.long : labels.short, " "] }), trade.leverage != null && `${formatNumber(trade.leverage, locale)}×`] })] }), _jsxs("span", { className: 'hig-trade-row-result', children: [_jsx("strong", { className: 'hig-trade-pnl', "data-tone": tone, children: _jsx(AnimatedNumberReadout, { value: trade.pnl, options: pnlOptions }) }), trade.time && _jsx("span", { children: trade.time })] }), onSelect && chevron] });
|
|
18
|
+
return _jsx("li", { children: onSelect ? _jsx("button", { type: 'button', className: 'hig-trade-row', "aria-label": [trade.name, side, formatNumber(trade.pnl, locale, pnlOptions), trade.time].filter(Boolean).join(', '), onClick: () => onSelect(trade), children: content }) : _jsx("div", { className: 'hig-trade-row', children: content }) }, trade.id);
|
|
19
|
+
};
|
|
20
|
+
return _jsxs("section", { ...rest, className: `hig-trade-history-list${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction }), trades.length === 0 ? _jsx("p", { className: 'hig-swap-empty', role: 'status', children: labels.empty }) : _jsx("ul", { className: 'hig-trade-rows', "aria-label": labels.title, children: trades.map(row) })] });
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Aggregate entry. TradeEntry needs @radix-ui/react-dialog; import single blocks from `@bloxwap/hig/react/blocks/<name>` to avoid overlay peers. SwapSheet (Vaul) is only at `blocks/swap-sheet`. */
|
|
2
|
+
export { MarketRow } from './blocks/market-row.js';
|
|
3
|
+
export { TradeEntry } from './blocks/trade-entry.js';
|
|
4
|
+
export { InstallCommand } from './blocks/install-command.js';
|
|
5
|
+
export { MarketingHero } from './blocks/marketing-hero.js';
|
|
6
|
+
export { AccountBlock, AssetBalanceRow, accountRows, assetValue, type AccountBlockProps, type AccountAsset, type AssetArtwork, type AssetBalanceRowProps } from './blocks/account-block.js';
|
|
7
|
+
export { LanguageBlock, filterLanguages, type LanguageBlockProps, type LanguageOption } from './blocks/language-block.js';
|
|
8
|
+
export { TokenActionBlock, tokenActionLabel, type TokenActionBlockProps, type TokenAction, type TokenActionId } from './blocks/token-action-block.js';
|
|
9
|
+
export { ManagePositionBlock, positionCorridor, type ManagePositionBlockProps, type ManagePositionBlockLabels, type ManagePositionBlockAction, type ManagePositionBlockSummary } from './blocks/manage-position-block.js';
|
|
10
|
+
export { TargetBlock, targetLayout, targetFormat, type TargetBlockProps, type TargetBlockLabels, type TargetKind, type TargetUnit, type TargetPrice } from './blocks/target-block.js';
|
|
11
|
+
export { PositionBlock, type PositionBlockProps, type PositionBlockDetail, type PositionBlockFigure, type PositionBlockRow, type PositionBlockFlag } from './blocks/position-block.js';
|
|
12
|
+
export { ProfileBlock, type ProfileBlockProps, type ProfileSection, type ProfileRow, type ProfileStatus } from './blocks/profile-block.js';
|
|
13
|
+
export { RewardBlock, rewardProgress, type RewardBlockProps, type RewardPromo, type RewardEntry } from './blocks/reward-block.js';
|
|
14
|
+
export { SoundHapticsBlock, soundLevel, type SoundHapticsBlockProps, type SoundSection, type SoundVolume } from './blocks/sound-haptics-block.js';
|
|
15
|
+
export { SignalsBlock, type SignalsBlockProps, type SignalsGroup, type SignalsItem } from './blocks/signals-block.js';
|
|
16
|
+
export { NotificationsBlock, type NotificationsBlockProps, type NotificationsItem } from './blocks/notifications-block.js';
|
|
17
|
+
export { TradeHistoryListBlock, tradeHistorySide, type TradeHistoryListBlockProps, type TradeHistoryListLabels, type TradeHistoryItem } from './blocks/trade-history-list-block.js';
|
|
18
|
+
export { TradeHistoryDetailBlock, type TradeHistoryDetailBlockProps, type TradeHistoryDetailLabels, type TradeHistoryDetail, type TradeHistoryAction } from './blocks/trade-history-detail-block.js';
|
|
19
|
+
export { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker, type FromPickerBlockProps, type ToPickerBlockProps, type FromPickerProps, type ToPickerProps, type PickerListProps } from './blocks/pickers.js';
|
|
20
|
+
export { SwapPanelBlock, SwapPanel, swapAction, type SwapPanelBlockProps, type SwapPanelProps, type SwapToken, type SwapChain, type SwapAction, type SwapDenomination, type SwapWallet, type SwapFee, type SwapReceive, type SwapDestination, type SwapDetail } from './blocks/swap-panel-block.js';
|