@bloxwap/hig 0.6.0 → 0.7.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/chart/README.md +1 -1
- package/contracts/README.md +1 -1
- package/contracts/dist/index.d.ts +16 -0
- package/contracts/dist/index.js +22 -0
- package/contracts/dist/messages.d.ts +6 -0
- package/contracts/dist/messages.js +3 -1
- package/feedback/README.md +1 -1
- package/native/README.md +1 -1
- package/native/dist/account-block.d.ts +53 -7
- package/native/dist/account-block.js +42 -9
- package/native/dist/animated-number-model.d.ts +7 -1
- package/native/dist/animated-number-model.js +50 -1
- package/native/dist/animated-number.d.ts +3 -1
- package/native/dist/animated-number.js +8 -5
- package/native/dist/asset-balance-row.d.ts +17 -1
- package/native/dist/asset-balance-row.js +13 -8
- package/native/dist/bar-mark.d.ts +14 -2
- package/native/dist/bar-mark.js +19 -5
- package/native/dist/bar-pnl.js +5 -4
- package/native/dist/blocks.d.ts +8 -14
- package/native/dist/blocks.js +5 -6
- package/native/dist/button.js +3 -1
- package/native/dist/data.d.ts +1 -1
- package/native/dist/data.js +6 -4
- package/native/dist/field.d.ts +14 -4
- package/native/dist/field.js +33 -7
- package/native/dist/figure.d.ts +23 -0
- package/native/dist/figure.js +10 -0
- package/native/dist/language-block.d.ts +5 -1
- package/native/dist/language-block.js +3 -3
- package/native/dist/list-group.d.ts +42 -8
- package/native/dist/list-group.js +71 -13
- package/native/dist/manage-position-block.d.ts +28 -2
- package/native/dist/manage-position-block.js +36 -11
- package/native/dist/market-row.d.ts +46 -0
- package/native/dist/market-row.js +30 -0
- package/native/dist/notifications-block.d.ts +30 -2
- package/native/dist/notifications-block.js +16 -8
- package/native/dist/pickers.d.ts +24 -2
- package/native/dist/pickers.js +16 -8
- package/native/dist/position-block.d.ts +66 -10
- package/native/dist/position-block.js +45 -11
- package/native/dist/profile-block.d.ts +29 -5
- package/native/dist/profile-block.js +25 -5
- package/native/dist/provider.d.ts +9 -3
- package/native/dist/provider.js +7 -3
- package/native/dist/radio-group.d.ts +9 -3
- package/native/dist/radio-group.js +4 -5
- package/native/dist/recipes.d.ts +6 -0
- package/native/dist/recipes.js +6 -0
- package/native/dist/reward-block.d.ts +45 -6
- package/native/dist/reward-block.js +30 -12
- package/native/dist/screen-header.d.ts +49 -0
- package/native/dist/screen-header.js +29 -0
- package/native/dist/selection.d.ts +2 -2
- package/native/dist/setting-header.d.ts +2 -8
- package/native/dist/setting-header.js +2 -11
- package/native/dist/setting-switch.d.ts +14 -1
- package/native/dist/setting-switch.js +5 -2
- package/native/dist/signals-block.d.ts +26 -2
- package/native/dist/signals-block.js +14 -4
- package/native/dist/sound-haptics-block.d.ts +29 -2
- package/native/dist/sound-haptics-block.js +18 -7
- package/native/dist/status.d.ts +6 -5
- package/native/dist/status.js +5 -5
- package/native/dist/sticky-header.d.ts +28 -0
- package/native/dist/sticky-header.js +21 -0
- package/native/dist/surface.d.ts +3 -1
- package/native/dist/surface.js +2 -1
- package/native/dist/swap-panel-block.d.ts +2 -1
- package/native/dist/swap-panel-block.js +9 -6
- package/native/dist/swap-parts.d.ts +5 -3
- package/native/dist/swap-parts.js +2 -2
- package/native/dist/swap-shared.d.ts +6 -0
- package/native/dist/swap-views.js +5 -3
- package/native/dist/switch-row.d.ts +3 -2
- package/native/dist/switch-row.js +5 -3
- package/native/dist/switch.d.ts +4 -2
- package/native/dist/switch.js +3 -3
- package/native/dist/target-block.d.ts +33 -6
- package/native/dist/target-block.js +19 -6
- package/native/dist/token-action-block.d.ts +17 -9
- package/native/dist/token-action-block.js +14 -6
- package/native/dist/trade-history-detail-block.d.ts +26 -1
- package/native/dist/trade-history-detail-block.js +17 -9
- package/native/dist/trade-history-list-block.d.ts +71 -5
- package/native/dist/trade-history-list-block.js +50 -15
- package/native/dist/wallet-address-core.d.ts +25 -0
- package/native/dist/wallet-address-core.js +31 -0
- package/native/dist/wallet-address.d.ts +6 -10
- package/native/dist/wallet-address.js +16 -20
- package/native-fonts/README.md +1 -1
- package/og-fonts/README.md +1 -1
- package/package.json +21 -1
- package/react/README.md +1 -1
- package/react/dist/animated-number-model.d.ts +6 -0
- package/react/dist/animated-number-model.js +33 -0
- package/react/dist/animated-number.d.ts +5 -1
- package/react/dist/animated-number.js +12 -8
- package/react/dist/asset-balance-row.d.ts +17 -1
- package/react/dist/asset-balance-row.js +11 -3
- package/react/dist/bar-mark.d.ts +5 -2
- package/react/dist/bar-mark.js +5 -3
- package/react/dist/blocks/account-block.d.ts +53 -7
- package/react/dist/blocks/account-block.js +45 -10
- package/react/dist/blocks/language-block.d.ts +5 -1
- package/react/dist/blocks/language-block.js +6 -5
- package/react/dist/blocks/manage-position-block.d.ts +28 -2
- package/react/dist/blocks/manage-position-block.js +23 -4
- package/react/dist/blocks/market-row.d.ts +20 -9
- package/react/dist/blocks/market-row.js +12 -4
- package/react/dist/blocks/notifications-block.d.ts +25 -2
- package/react/dist/blocks/notifications-block.js +11 -2
- package/react/dist/blocks/pickers.d.ts +21 -1
- package/react/dist/blocks/pickers.js +30 -10
- package/react/dist/blocks/position-block.d.ts +34 -11
- package/react/dist/blocks/position-block.js +16 -5
- package/react/dist/blocks/profile-block.d.ts +29 -6
- package/react/dist/blocks/profile-block.js +31 -5
- package/react/dist/blocks/reward-block.d.ts +53 -14
- package/react/dist/blocks/reward-block.js +20 -10
- package/react/dist/blocks/screen-header.d.ts +26 -2
- package/react/dist/blocks/screen-header.js +13 -5
- package/react/dist/blocks/setting-switch.d.ts +14 -1
- package/react/dist/blocks/setting-switch.js +8 -4
- package/react/dist/blocks/signals-block.d.ts +21 -2
- package/react/dist/blocks/signals-block.js +5 -5
- package/react/dist/blocks/sound-haptics-block.d.ts +25 -3
- package/react/dist/blocks/sound-haptics-block.js +11 -7
- package/react/dist/blocks/sticky-header.d.ts +9 -0
- package/react/dist/blocks/sticky-header.js +43 -0
- package/react/dist/blocks/swap/amount-card.js +2 -1
- package/react/dist/blocks/swap/settings.js +2 -2
- package/react/dist/blocks/swap/shared.d.ts +7 -1
- package/react/dist/blocks/swap/shared.js +6 -4
- package/react/dist/blocks/swap-panel-block.d.ts +2 -0
- package/react/dist/blocks/swap-panel-block.js +6 -6
- package/react/dist/blocks/target-block.d.ts +28 -6
- package/react/dist/blocks/target-block.js +17 -9
- package/react/dist/blocks/token-action-block.d.ts +17 -8
- package/react/dist/blocks/token-action-block.js +9 -6
- package/react/dist/blocks/trade-history-detail-block.d.ts +21 -1
- package/react/dist/blocks/trade-history-detail-block.js +5 -4
- package/react/dist/blocks/trade-history-list-block.d.ts +29 -5
- package/react/dist/blocks/trade-history-list-block.js +15 -8
- package/react/dist/blocks.d.ts +8 -8
- package/react/dist/blocks.js +2 -2
- package/react/dist/button.js +6 -4
- package/react/dist/data.js +3 -3
- package/react/dist/field.d.ts +14 -4
- package/react/dist/field.js +19 -6
- package/react/dist/figure.d.ts +23 -0
- package/react/dist/figure.js +12 -0
- package/react/dist/list-group.d.ts +41 -8
- package/react/dist/list-group.js +44 -12
- package/react/dist/provider.d.ts +40 -3
- package/react/dist/provider.js +63 -6
- package/react/dist/selection.d.ts +8 -2
- package/react/dist/selection.js +11 -6
- package/react/dist/styles.css +164 -9
- package/react/dist/surface.d.ts +5 -1
- package/react/dist/surface.js +1 -1
- package/react/dist/wallet-address-core.d.ts +23 -0
- package/react/dist/wallet-address-core.js +24 -0
- package/react/dist/wallet-address.d.ts +6 -12
- package/react/dist/wallet-address.js +5 -16
- package/tokens/README.md +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
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
4
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
|
-
import { useControllable, useHIG } from '../provider.js';
|
|
5
|
+
import { PressDecoration, useControllable, useHIG } from '../provider.js';
|
|
6
6
|
import { Button, IconButton } from '../button.js';
|
|
7
7
|
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
8
8
|
import { notify } from '../notify.js';
|
|
@@ -158,18 +158,18 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
|
|
|
158
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
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
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 })] })] });
|
|
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 ?
|
|
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 ? _jsxs("button", { type: 'button', className: 'hig-swap-receive', "aria-label": (messages.copyAddress ?? en.copyAddress) + ': ' + view.address, onClick: copyAddress, children: [content, _jsx(PressDecoration, { kind: 'row' })] }) : _jsx("div", { className: 'hig-swap-receive', children: content }); };
|
|
162
162
|
const card = (side) => {
|
|
163
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;
|
|
164
164
|
const cardUnits = side === 'from' ? units : receivedUnits, cardUsd = side === 'from' ? usd : receivedUsd;
|
|
165
165
|
const shown = side === 'from' ? input : mode === 'token' ? receivedUnits : receivedUsd;
|
|
166
|
-
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) :
|
|
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 })] })] })] })] });
|
|
166
|
+
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), children: _jsx(PressDecoration, { kind: 'row' }) }), _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) :
|
|
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), children: _jsx(PressDecoration, { kind: 'row' }) }), _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 })] })] })] })] });
|
|
168
168
|
};
|
|
169
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.
|
|
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)) })] });
|
|
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, children: _jsx(PressDecoration, { kind: 'row' }) }), _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, formattedValue: row.formattedValue, animateFormatted: !!row.formattedValue }) : row.value })] }, row.label)) })] });
|
|
171
171
|
const fromCard = card('from'), toCard = fixedCard || card('to');
|
|
172
|
-
const body = view === 'main' ? _jsxs(_Fragment, { children: [title && _jsxs("div", { className: 'hig-swap-view-header', "data-plain": onBack ? undefined : 'true', children: [onBack &&
|
|
172
|
+
const body = view === 'main' ? _jsxs(_Fragment, { children: [title && _jsxs("div", { className: 'hig-swap-view-header', "data-plain": onBack ? undefined : 'true', children: [onBack && _jsxs("button", { type: 'button', className: 'hig-swap-back', "aria-label": messages.back ?? en.back, onClick: onBack, children: [_jsx(SwapIcon, { name: 'back' }), _jsx(PressDecoration, { kind: '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 }) }) : _jsxs("button", { type: 'button', "aria-label": (messages.swapFlip ?? en.swapFlip), disabled: !from || !to, onClick: flip, children: [_jsx(SwapIcon, { name: 'flip', size: 16 }), _jsx(PressDecoration, { kind: 'icon-button', disabled: !from || !to })] }) }), 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 })
|
|
173
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 })
|
|
174
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 });
|
|
175
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 })] });
|
|
@@ -37,16 +37,18 @@ export interface TargetBlockProps extends Omit<React.HTMLAttributes<HTMLElement>
|
|
|
37
37
|
/** Price the order triggers at. Defaults to `value` when the unit is `price`; otherwise unknown until the host supplies it. */
|
|
38
38
|
trigger?: number | null;
|
|
39
39
|
unit: TargetUnit;
|
|
40
|
-
/** Units offered, in order. Defaults to all three; one unit hides the control. */
|
|
41
|
-
units?: readonly TargetUnit[];
|
|
40
|
+
/** Units offered, in order. Defaults to all three; one unit hides the control. `{unit, disabled}` shows a unit that cannot be chosen now, dimmed. */
|
|
41
|
+
units?: readonly (TargetUnit | TargetUnitOption)[];
|
|
42
42
|
onUnitChange?: (unit: TargetUnit) => void;
|
|
43
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
44
|
value: number | null;
|
|
45
45
|
onValueChange?: (value: number) => void;
|
|
46
|
-
/** Quick choices in the current unit. The one equal to `value` is shown selected. */
|
|
47
|
-
presets?: readonly number[];
|
|
46
|
+
/** Quick choices in the current unit. The one equal to `value` is shown selected. `{value, disabled}` shows a choice that cannot be taken now, dimmed. */
|
|
47
|
+
presets?: readonly (number | TargetPreset)[];
|
|
48
48
|
/** Shows the Custom row; the host opens its own entry. */
|
|
49
49
|
onCustom?: () => void;
|
|
50
|
+
/** The value the host's own entry set, in the current unit. The Custom row then shows it on its trailing edge and reads as selected, and no quick choice does. Has no effect without `onCustom`; null keeps the row a toggle that reads as not selected. */
|
|
51
|
+
customValue?: number | null;
|
|
50
52
|
/** Format of prices. Defaults to US dollars. */
|
|
51
53
|
priceOptions?: Intl.NumberFormatOptions;
|
|
52
54
|
/** 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. */
|
|
@@ -58,9 +60,29 @@ export interface TargetBlockProps extends Omit<React.HTMLAttributes<HTMLElement>
|
|
|
58
60
|
/** Shows Cancel beside the confirming action. */
|
|
59
61
|
onCancel?: () => void;
|
|
60
62
|
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. */
|
|
63
|
+
/** 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, unless `headerActionBesideInfo` is set. */
|
|
62
64
|
headerAction?: React.ReactNode;
|
|
65
|
+
/** Set true to keep the info button when `headerAction` is given: the info button comes first and `headerAction` sits on the trailing edge. */
|
|
66
|
+
headerActionBesideInfo?: boolean;
|
|
67
|
+
/** `id` of the heading, so a dialog or sheet can name itself with `aria-labelledby`. */
|
|
68
|
+
headingId?: string;
|
|
69
|
+
/** Pins the header to the top of the nearest scrolling container, transparent at rest and filled with `--hig-sticky-header-background` once content scrolls under it. */
|
|
70
|
+
stickyHeader?: boolean;
|
|
63
71
|
}
|
|
72
|
+
/** A quick choice that can be shown dimmed. */
|
|
73
|
+
export interface TargetPreset {
|
|
74
|
+
value: number;
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/** A unit that can be shown dimmed. */
|
|
78
|
+
export interface TargetUnitOption {
|
|
79
|
+
unit: TargetUnit;
|
|
80
|
+
disabled?: boolean;
|
|
81
|
+
}
|
|
82
|
+
/** The quick choices as `{value, disabled}`, whichever form the host gave. */
|
|
83
|
+
export declare function targetPresets(presets: readonly (number | TargetPreset)[]): TargetPreset[];
|
|
84
|
+
/** The units as `{unit, disabled}`, whichever form the host gave. */
|
|
85
|
+
export declare function targetUnits(units: readonly (TargetUnit | TargetUnitOption)[]): TargetUnitOption[];
|
|
64
86
|
/** 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
87
|
export declare function targetFormat(unit: TargetUnit, priceOptions?: Intl.NumberFormatOptions, short?: number): Intl.NumberFormatOptions;
|
|
66
88
|
/**
|
|
@@ -78,4 +100,4 @@ export declare function targetLayout({ entry, trigger }: {
|
|
|
78
100
|
to: number;
|
|
79
101
|
};
|
|
80
102
|
/** 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;
|
|
103
|
+
export declare function TargetBlock({ kind, labels, position, orderType, note, entry, trigger, unit, units, onUnitChange, value, onValueChange, presets, onCustom, customValue, priceOptions, surface, onSubmit, submitDisabled, busy, onCancel, onBack, headerAction, headerActionBesideInfo, headingId, stickyHeader, className, ...rest }: TargetBlockProps): React.JSX.Element;
|
|
@@ -3,12 +3,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useId, useRef, useState } from 'react';
|
|
4
4
|
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
5
5
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
6
|
-
import { useHIG } from '../provider.js';
|
|
6
|
+
import { PressDecoration, usePresentNumber, useHIG, useNumberLocale } from '../provider.js';
|
|
7
7
|
import { Button } from '../button.js';
|
|
8
8
|
import { SegmentedControl } from '../selection.js';
|
|
9
9
|
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
10
10
|
import { ScreenHeader } from './screen-header.js';
|
|
11
11
|
import { SwapIcon } from './swap/shared.js';
|
|
12
|
+
/** The quick choices as `{value, disabled}`, whichever form the host gave. */
|
|
13
|
+
export function targetPresets(presets) { return presets.map(preset => typeof preset === 'number' ? { value: preset } : preset); }
|
|
14
|
+
/** The units as `{unit, disabled}`, whichever form the host gave. */
|
|
15
|
+
export function targetUnits(units) { return units.map(unit => typeof unit === 'string' ? { unit } : unit); }
|
|
12
16
|
const usd = { style: 'currency', currency: 'USD' }, allUnits = ['dollar', 'price', 'percent'];
|
|
13
17
|
const known = (value) => value != null && Number.isFinite(value);
|
|
14
18
|
/** 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. */
|
|
@@ -43,8 +47,10 @@ export function targetLayout({ entry, trigger }) {
|
|
|
43
47
|
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
48
|
}
|
|
45
49
|
/** 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
|
|
50
|
+
export function TargetBlock({ kind, labels, position, orderType, note, entry, trigger, unit, units = allUnits, onUnitChange, value, onValueChange, presets = [], onCustom, customValue, priceOptions = usd, surface = false, onSubmit, submitDisabled, busy, onCancel, onBack, headerAction, headerActionBesideInfo, headingId, stickyHeader, className, ...rest }) {
|
|
51
|
+
const { messages } = useHIG();
|
|
52
|
+
const locale = useNumberLocale();
|
|
53
|
+
const present = usePresentNumber();
|
|
48
54
|
const id = useId(), noteId = useId();
|
|
49
55
|
const [open, setOpen] = useState(false);
|
|
50
56
|
const anchor = useRef(null);
|
|
@@ -52,14 +58,16 @@ export function TargetBlock({ kind, labels, position, orderType, note, entry, tr
|
|
|
52
58
|
useEffect(() => { if (!open)
|
|
53
59
|
return; const outside = (event) => { if (!anchor.current?.contains(event.target))
|
|
54
60
|
setOpen(false); }; document.addEventListener('pointerdown', outside); return () => document.removeEventListener('pointerdown', outside); }, [open]);
|
|
55
|
-
const info = note && labels.info && !headerAction ? labels.info : undefined;
|
|
61
|
+
const info = note && labels.info && (!headerAction || headerActionBesideInfo) ? labels.info : undefined;
|
|
62
|
+
const custom = onCustom && known(customValue) ? customValue : null;
|
|
63
|
+
const infoButton = info && _jsxs("span", { ref: anchor, className: 'hig-target-info', onKeyDown: event => { if (event.key === 'Escape' && open) {
|
|
64
|
+
event.stopPropagation();
|
|
65
|
+
setOpen(false);
|
|
66
|
+
} }, onBlur: event => { if (!event.currentTarget.contains(event.relatedTarget))
|
|
67
|
+
setOpen(false); }, children: [_jsxs("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' }), _jsx(PressDecoration, { kind: 'back' })] }), open && _jsx("span", { id: noteId, role: 'status', className: 'hig-popover hig-target-popover', children: note })] });
|
|
56
68
|
const target = trigger !== undefined ? trigger : unit === 'price' ? value : null;
|
|
57
69
|
const { positions, order, from, to } = targetLayout({ entry, trigger: target });
|
|
58
70
|
const prices = { entry, trigger: target };
|
|
59
71
|
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", {
|
|
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 })] })] });
|
|
72
|
+
return _jsxs("section", { ...rest, className: `hig-target-block${className ? ` ${className}` : ''}`, "data-kind": kind, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, headingId: headingId, stickyHeader: stickyHeader, action: info ? headerAction ? _jsxs("span", { className: 'hig-target-header-actions', children: [infoButton, headerAction] }) : infoButton : 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: targetUnits(units).map(option => ({ value: option.unit, label: labels.units[option.unit], disabled: option.disabled })), value: unit, onValueChange: next => onUnitChange?.(next) }), onCustom && (custom === null ? _jsxs("button", { type: 'button', className: 'hig-swap-setting', "aria-pressed": customValue !== undefined ? false : undefined, onClick: onCustom, children: [_jsx("span", { children: labels.custom }), _jsx(SwapIcon, { name: 'chevron', size: 16 }), _jsx(PressDecoration, { kind: 'row' })] }) : _jsxs("button", { type: 'button', className: 'hig-swap-setting', "aria-pressed": 'true', onClick: onCustom, children: [_jsx("span", { children: labels.custom }), _jsxs("span", { className: 'hig-swap-setting-value', children: [formatNumber(custom, locale, present(targetFormat(unit, priceOptions))), _jsx(SwapIcon, { name: 'chevron', size: 16 })] }), _jsx(PressDecoration, { kind: 'row' })] })), presets.length > 0 && _jsx("div", { className: 'hig-target-presets', children: targetPresets(presets).map(({ value: preset, disabled }) => { const selected = custom === null && preset === value; return _jsx(Button, { fullWidth: true, intent: selected ? intent : 'secondary', "aria-pressed": selected, disabled: disabled, onClick: () => onValueChange?.(preset), children: formatNumber(preset, locale, present(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
73
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { HIGMessages } from '@bloxwap/hig/contracts/messages';
|
|
3
3
|
import { type BarMarkElement } from '../bar-mark.js';
|
|
4
|
-
export type { BarMarkElement, BarMarkTone } from '../bar-mark.js';
|
|
4
|
+
export type { BarMarkElement, BarMarkFigure, BarMarkTone } from '../bar-mark.js';
|
|
5
5
|
/** Actions with a built-in, translated label. */
|
|
6
6
|
export type TokenActionId = 'send' | 'receive' | 'stake' | 'unstake';
|
|
7
7
|
export interface TokenAction {
|
|
@@ -16,22 +16,31 @@ export interface TokenAction {
|
|
|
16
16
|
export interface TokenActionBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
|
|
17
17
|
/** Heading, usually the ticker: HYPE. */
|
|
18
18
|
symbol: string;
|
|
19
|
-
/** Title of the assets bar: Hyperliquid. */
|
|
20
|
-
name
|
|
19
|
+
/** Title of the assets bar: Hyperliquid. Needed only with `assets`; the symbol stands in without it. */
|
|
20
|
+
name?: string;
|
|
21
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
22
|
value?: number | null;
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
|
|
23
|
+
/** The holding in token units, for a token with no dollar value: with `value` left out or `null` it is drawn in place of the dollar total. */
|
|
24
|
+
units?: number | null;
|
|
25
|
+
/** Host text after the units, such as ` BLOX`. */
|
|
26
|
+
unitsSuffix?: string;
|
|
27
|
+
/** Format of the units. Defaults to at most six fraction digits. */
|
|
28
|
+
unitsOptions?: Intl.NumberFormatOptions;
|
|
29
|
+
/** Where the token is held: Staked, Core, Paper. Leave it out to draw no assets bar. */
|
|
30
|
+
assets?: readonly BarMarkElement[];
|
|
31
|
+
/** The chains the token sits on. Leave it out to draw no chains bar. */
|
|
32
|
+
chains?: readonly BarMarkElement[];
|
|
27
33
|
/** Title of the chains bar. Defaults to the built-in “Chains”. */
|
|
28
34
|
chainsTitle?: string;
|
|
29
35
|
actions: readonly TokenAction[];
|
|
30
36
|
onBack?: () => void;
|
|
31
37
|
/** A control on the trailing edge of the header, usually an `IconButton`. */
|
|
32
38
|
headerAction?: React.ReactNode;
|
|
39
|
+
/** A line under the actions, for example why some are missing. `noteTone` tints it as in `SwapPanelBlock`. */
|
|
40
|
+
note?: React.ReactNode;
|
|
41
|
+
noteTone?: 'muted' | 'warning' | 'negative';
|
|
33
42
|
}
|
|
34
43
|
/** The text of an action: its `label`, the built-in label for a known id, or the id itself. */
|
|
35
44
|
export declare const tokenActionLabel: (action: TokenAction, messages?: Partial<HIGMessages>) => string;
|
|
36
45
|
/** 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;
|
|
46
|
+
export declare function TokenActionBlock({ symbol, name, value, units, unitsSuffix, unitsOptions, assets, chains, chainsTitle, actions, onBack, headerAction, note, noteTone, className, ...rest }: TokenActionBlockProps): React.JSX.Element;
|
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
4
4
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
|
-
import { useHIG } from '../provider.js';
|
|
5
|
+
import { useHIG, useNumberLocale } from '../provider.js';
|
|
6
6
|
import { Button } from '../button.js';
|
|
7
7
|
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
8
8
|
import { BarMark } from '../bar-mark.js';
|
|
9
9
|
import { ScreenHeader } from './screen-header.js';
|
|
10
|
-
const usd = { style: 'currency', currency: 'USD' }, held = (value) => Number.isFinite(value) && value > 0;
|
|
10
|
+
const usd = { style: 'currency', currency: 'USD' }, unitsFormat = { maximumFractionDigits: 6 }, held = (value) => Number.isFinite(value) && value > 0;
|
|
11
11
|
/** The text of an action: its `label`, the built-in label for a known id, or the id itself. */
|
|
12
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
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
|
|
16
|
-
const
|
|
17
|
-
|
|
14
|
+
export function TokenActionBlock({ symbol, name, value, units, unitsSuffix, unitsOptions = unitsFormat, assets, chains, chainsTitle, actions, onBack, headerAction, note, noteTone = 'muted', className, ...rest }) {
|
|
15
|
+
const { messages } = useHIG();
|
|
16
|
+
const locale = useNumberLocale();
|
|
17
|
+
const total = value !== undefined ? value : (assets ?? []).reduce((sum, asset) => sum + (held(asset.value) ? asset.value : 0), 0);
|
|
18
|
+
// With no dollar value the units are the headline, as an AccountBlock row headlines them.
|
|
19
|
+
const headline = units !== undefined && value == null ? _jsx(AnimatedNumberReadout, { value: units, options: unitsOptions, suffix: unitsSuffix }, 'units') : _jsx(AnimatedNumberReadout, { value: total, options: usd }, 'value');
|
|
20
|
+
return _jsxs("section", { ...rest, className: `hig-token-card${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: symbol, onBack: onBack, action: headerAction }), (assets || chains) && _jsxs("div", { className: 'hig-token-bars', children: [assets && _jsx(BarMark, { surface: false, title: name ?? symbol, description: headline, elements: assets }), chains && _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)) }), note != null && note !== false && _jsx("p", { className: 'hig-swap-note hig-token-note', "data-tone": noteTone, role: 'note', children: note })] });
|
|
18
21
|
}
|
|
@@ -20,6 +20,8 @@ export interface TradeHistoryDetail {
|
|
|
20
20
|
options?: Intl.NumberFormatOptions;
|
|
21
21
|
prefix?: string;
|
|
22
22
|
suffix?: string;
|
|
23
|
+
/** With a number `value`: host-formatted text drawn and read in place of Intl's, still moving place by place. */
|
|
24
|
+
formattedValue?: string;
|
|
23
25
|
}
|
|
24
26
|
export interface TradeHistoryAction {
|
|
25
27
|
id: string;
|
|
@@ -34,13 +36,21 @@ export interface TradeHistoryDetailBlockProps extends Omit<React.HTMLAttributes<
|
|
|
34
36
|
/** Asset name: Amazon. */
|
|
35
37
|
name: string;
|
|
36
38
|
icon?: AssetArtwork;
|
|
39
|
+
/** Short ticker for the fallback disc when there is no `icon`: BTC. Without it the disc shows the first letters of the name. */
|
|
40
|
+
symbol?: string;
|
|
37
41
|
side: 'long' | 'short';
|
|
38
42
|
/** 20 reads `20×`. */
|
|
39
43
|
leverage?: number;
|
|
44
|
+
/** A short muted qualifier after the leverage, read with it: current. */
|
|
45
|
+
leverageNote?: string;
|
|
40
46
|
/** Net profit and loss in dollars. `null` reads as unknown. */
|
|
41
47
|
pnl: number | null;
|
|
48
|
+
/** Format of the headline result. Defaults to signed US dollars with up to four decimals. The provider's `numberFormat` is merged under it. */
|
|
49
|
+
pnlOptions?: Intl.NumberFormatOptions;
|
|
42
50
|
/** Return on margin as a fraction: 0.0284 reads +2.84%. */
|
|
43
51
|
pnlPercent?: number | null;
|
|
52
|
+
/** Format of the return on margin. Defaults to a signed percent with two decimals. */
|
|
53
|
+
percentOptions?: Intl.NumberFormatOptions;
|
|
44
54
|
/** 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
55
|
entry?: number;
|
|
46
56
|
exit?: number;
|
|
@@ -48,11 +58,21 @@ export interface TradeHistoryDetailBlockProps extends Omit<React.HTMLAttributes<
|
|
|
48
58
|
priceOptions?: Intl.NumberFormatOptions;
|
|
49
59
|
/** 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
60
|
details: readonly TradeHistoryDetail[];
|
|
61
|
+
/** One muted sentence under the details, such as that part of the record is missing. */
|
|
62
|
+
note?: string;
|
|
63
|
+
/** Short host text in a badge beside the title: Demo. */
|
|
64
|
+
badge?: string;
|
|
51
65
|
/** Actions in one row under the details, such as Save image and Share. */
|
|
52
66
|
actions?: readonly TradeHistoryAction[];
|
|
53
67
|
onBack?: () => void;
|
|
54
68
|
/** A control on the trailing edge of the header, usually an `IconButton`. */
|
|
55
69
|
headerAction?: React.ReactNode;
|
|
70
|
+
/** Ref to the summary (the asset line, the headline figure and the return), for a host that captures it as an image. */
|
|
71
|
+
summaryRef?: React.Ref<HTMLDivElement>;
|
|
72
|
+
/** Fills the summary, so an image captured from `summaryRef` is not transparent: `true` for the background role, or a CSS colour such as `var(--hig-overlay)` in a sheet. */
|
|
73
|
+
summaryBackground?: boolean | string;
|
|
74
|
+
/** Pins the header to the top of the nearest scrolling container, transparent at rest and filled with `--hig-sticky-header-background` once content scrolls under it. */
|
|
75
|
+
stickyHeader?: boolean;
|
|
56
76
|
}
|
|
57
77
|
/** 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;
|
|
78
|
+
export declare function TradeHistoryDetailBlock({ labels, name, icon, symbol, side, leverage, leverageNote, pnl, pnlOptions, pnlPercent, percentOptions, entry, exit, priceOptions, details, note, badge, actions, onBack, headerAction, summaryRef, summaryBackground, stickyHeader, className, ...rest }: TradeHistoryDetailBlockProps): React.JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
4
|
-
import {
|
|
4
|
+
import { useNumberLocale } from '../provider.js';
|
|
5
5
|
import { Button } from '../button.js';
|
|
6
6
|
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
7
7
|
import { BarPnl } from '../bar-pnl.js';
|
|
@@ -9,8 +9,9 @@ import { ScreenHeader } from './screen-header.js';
|
|
|
9
9
|
import { SwapNumber } from './swap/shared.js';
|
|
10
10
|
const pnlFormat = { style: 'currency', currency: 'USD', signDisplay: 'exceptZero', maximumFractionDigits: 4 }, percentFormat = { style: 'percent', minimumFractionDigits: 2, maximumFractionDigits: 2, signDisplay: 'exceptZero' };
|
|
11
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
|
|
12
|
+
export function TradeHistoryDetailBlock({ labels, name, icon, symbol, side, leverage, leverageNote, pnl, pnlOptions = pnlFormat, pnlPercent, percentOptions = percentFormat, entry, exit, priceOptions, details, note, badge, actions = [], onBack, headerAction, summaryRef, summaryBackground, stickyHeader, className, ...rest }) {
|
|
13
|
+
const locale = useNumberLocale();
|
|
14
14
|
const tone = pnl == null || pnl === 0 ? undefined : pnl > 0 ? 'up' : 'down';
|
|
15
|
-
|
|
15
|
+
const fill = summaryBackground === true ? 'var(--hig-background)' : typeof summaryBackground === 'string' && summaryBackground ? summaryBackground : undefined;
|
|
16
|
+
return _jsxs("section", { ...rest, className: `hig-trade-detail${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction, badge: badge, stickyHeader: stickyHeader }), _jsxs("div", { className: 'hig-trade-summary', children: [_jsxs("div", { ref: summaryRef, className: 'hig-trade-result', "data-tone": tone, style: fill ? { background: fill } : undefined, 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 ?? symbol ?? 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"] }), leverageNote && _jsxs(_Fragment, { children: [" ", _jsx("span", { className: 'hig-trade-leverage-note', children: leverageNote })] })] })] }), _jsxs("strong", { className: 'hig-trade-figure', children: [_jsxs("span", { className: 'hig-trade-caption hig-sr-only', children: [labels.netPnl, " "] }), _jsx(AnimatedNumberReadout, { value: pnl, options: pnlOptions })] }), pnlPercent !== undefined && _jsx("span", { className: 'hig-trade-return', children: pnlPercent === null ? labels.onMargin('—') : _jsx(SwapNumber, { template: labels.onMargin, value: pnlPercent, options: percentOptions }) })] }), 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, formattedValue: row.formattedValue, animateFormatted: !!row.formattedValue }) : row.value })] }, row.label)) }), note && _jsx("p", { className: 'hig-trade-note', children: note })] }), 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
17
|
}
|
|
@@ -8,21 +8,31 @@ export interface TradeHistoryListLabels {
|
|
|
8
8
|
short: string;
|
|
9
9
|
/** Shown in place of the rows when there are no trades. */
|
|
10
10
|
empty: string;
|
|
11
|
+
/** A second line under `empty`, in the muted colour: Closed trades appear here. */
|
|
12
|
+
emptyDescription?: string;
|
|
11
13
|
}
|
|
12
14
|
/** One closed trade. */
|
|
13
15
|
export interface TradeHistoryItem {
|
|
14
16
|
id: string;
|
|
15
17
|
/** Asset name: Amazon. */
|
|
16
18
|
name: string;
|
|
17
|
-
/**
|
|
19
|
+
/** Short ticker for the fallback disc when there is no `icon`: BTC. Without it the disc shows the first letters of the name. */
|
|
20
|
+
symbol?: string;
|
|
21
|
+
/** Round artwork: an image URL or a host element. Without it the row shows `symbol` or the first letters of the name. */
|
|
18
22
|
icon?: AssetArtwork;
|
|
19
23
|
side: 'long' | 'short';
|
|
20
24
|
/** 20 reads `20×`. */
|
|
21
25
|
leverage?: number;
|
|
26
|
+
/** A short muted qualifier after the leverage, read with it: current. Use it when the leverage was not recorded with the trade. */
|
|
27
|
+
leverageNote?: string;
|
|
22
28
|
/** Net profit and loss in dollars. `null` reads as unknown. */
|
|
23
29
|
pnl: number | null;
|
|
24
30
|
/** Host-formatted age or time of the close, shown under the result: `2d`. */
|
|
25
31
|
time?: string;
|
|
32
|
+
/** Small muted host text before the age, such as the wallet the trade came from: `0x22…22`. */
|
|
33
|
+
tag?: string;
|
|
34
|
+
/** Format of this trade's result, in place of the block's `pnlOptions`, for a host whose decimal ladder depends on the amount. */
|
|
35
|
+
pnlOptions?: Intl.NumberFormatOptions;
|
|
26
36
|
}
|
|
27
37
|
export interface TradeHistoryListBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title' | 'onSelect'> {
|
|
28
38
|
labels: TradeHistoryListLabels;
|
|
@@ -34,10 +44,24 @@ export interface TradeHistoryListBlockProps extends Omit<React.HTMLAttributes<HT
|
|
|
34
44
|
onBack?: () => void;
|
|
35
45
|
/** A control on the trailing edge of the header, usually an `IconButton`. */
|
|
36
46
|
headerAction?: React.ReactNode;
|
|
37
|
-
/** Format of the result. Defaults to signed US dollars at four significant digits: `+$1.412`, `+$17.90`, `-$0.6878`. */
|
|
47
|
+
/** Format of the result. Defaults to signed US dollars at four significant digits: `+$1.412`, `+$17.90`, `-$0.6878`. The provider's `numberFormat` is merged under it. */
|
|
38
48
|
pnlOptions?: Intl.NumberFormatOptions;
|
|
49
|
+
/** Draws rows of skeletons in place of the trades while the host loads them. */
|
|
50
|
+
loading?: boolean;
|
|
51
|
+
/** Host text that names the skeleton rows for assistive technology and announces them: Loading history. Without it they are only marked busy. */
|
|
52
|
+
loadingLabel?: string;
|
|
53
|
+
/** Why the trades could not load, in place of the rows, in the negative colour and announced. */
|
|
54
|
+
error?: string;
|
|
55
|
+
/** Host content under the header, above the rows: a partial-history notice or a mode banner. */
|
|
56
|
+
notice?: React.ReactNode;
|
|
57
|
+
/** Host content under the rows: paging, a spinner for the next page, a note. */
|
|
58
|
+
footer?: React.ReactNode;
|
|
59
|
+
/** Pins the header to the top of the nearest scrolling container, transparent at rest and filled with `--hig-sticky-header-background` once the rows scroll under it. */
|
|
60
|
+
stickyHeader?: boolean;
|
|
39
61
|
}
|
|
40
62
|
/** How a row reads its side: `Short 20×`, or `Short` without leverage. */
|
|
41
|
-
export declare const tradeHistorySide: (trade: Pick<TradeHistoryItem, 'side' | 'leverage'
|
|
42
|
-
|
|
43
|
-
|
|
63
|
+
export declare const tradeHistorySide: (trade: Pick<TradeHistoryItem, 'side' | 'leverage'> & {
|
|
64
|
+
leverageNote?: string;
|
|
65
|
+
}, labels: Pick<TradeHistoryListLabels, 'long' | 'short'>, locale?: string) => string;
|
|
66
|
+
/** A history of closed trades as one screen: a header, then one row per trade with the asset, its side and leverage in the market direction colour, and the net result in the market direction colour over its age. */
|
|
67
|
+
export declare function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions, loading, loadingLabel, error, notice, footer, stickyHeader, className, ...rest }: TradeHistoryListBlockProps): React.JSX.Element;
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
4
|
-
import {
|
|
4
|
+
import { PressDecoration, usePresentNumber, useNumberLocale } from '../provider.js';
|
|
5
5
|
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
6
6
|
import { ScreenHeader } from './screen-header.js';
|
|
7
7
|
const pnlFormat = { style: 'currency', currency: 'USD', signDisplay: 'exceptZero', minimumSignificantDigits: 4, maximumSignificantDigits: 4 };
|
|
8
|
+
const skeletons = [0, 1, 2, 3];
|
|
8
9
|
/** 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
|
+
export const tradeHistorySide = (trade, labels, locale) => `${trade.side === 'long' ? labels.long : labels.short}${trade.leverage != null ? ` ${formatNumber(trade.leverage, locale)}×` : ''}${trade.leverageNote ? ` ${trade.leverageNote}` : ''}`;
|
|
10
11
|
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
12
|
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
|
|
13
|
-
export function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions = pnlFormat, className, ...rest }) {
|
|
14
|
-
const
|
|
13
|
+
/** A history of closed trades as one screen: a header, then one row per trade with the asset, its side and leverage in the market direction colour, and the net result in the market direction colour over its age. */
|
|
14
|
+
export function TradeHistoryListBlock({ labels, trades, onSelect, onBack, headerAction, pnlOptions = pnlFormat, loading, loadingLabel, error, notice, footer, stickyHeader, className, ...rest }) {
|
|
15
|
+
const locale = useNumberLocale();
|
|
16
|
+
const present = usePresentNumber();
|
|
15
17
|
const row = (trade) => {
|
|
18
|
+
const result = trade.pnlOptions ?? pnlOptions;
|
|
16
19
|
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)}
|
|
18
|
-
return _jsx("li", { children: onSelect ?
|
|
20
|
+
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.symbol ?? 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)}×`, trade.leverageNote && _jsx("span", { className: 'hig-trade-row-note', children: trade.leverageNote })] })] }), _jsxs("span", { className: 'hig-trade-row-result', children: [_jsx("strong", { className: 'hig-trade-pnl', "data-tone": tone, children: _jsx(AnimatedNumberReadout, { value: trade.pnl, options: result }) }), trade.tag ? _jsxs("span", { className: 'hig-trade-row-meta', children: [_jsx("span", { className: 'hig-trade-row-tag', children: trade.tag }), trade.time && _jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": 'true', children: "\u00B7" }), _jsx("span", { children: trade.time })] })] }) : trade.time && _jsx("span", { children: trade.time })] }), onSelect && chevron] });
|
|
21
|
+
return _jsx("li", { children: onSelect ? _jsxs("button", { type: 'button', className: 'hig-trade-row', "aria-label": [trade.name, side, formatNumber(trade.pnl, locale, present(result)), trade.tag, trade.time].filter(Boolean).join(', '), onClick: () => onSelect(trade), children: [content, _jsx(PressDecoration, { kind: 'row' })] }) : _jsx("div", { className: 'hig-trade-row', children: content }) }, trade.id);
|
|
19
22
|
};
|
|
20
|
-
|
|
23
|
+
const body = loading ? _jsxs(_Fragment, { children: [loadingLabel && _jsx("p", { className: 'hig-sr-only', role: 'status', children: loadingLabel }), _jsx("div", { className: 'hig-trade-rows', "aria-busy": 'true', children: skeletons.map(index => _jsx("div", { className: 'hig-skeleton hig-trade-skeleton', "aria-hidden": 'true' }, index)) })] })
|
|
24
|
+
: error ? _jsx("p", { className: 'hig-swap-empty hig-trade-error', role: 'alert', children: error })
|
|
25
|
+
: trades.length === 0 ? _jsx("p", { className: 'hig-swap-empty', role: 'status', children: labels.emptyDescription ? _jsxs(_Fragment, { children: [_jsx("strong", { className: 'hig-trade-empty-title', children: labels.empty }), _jsx("span", { className: 'hig-trade-empty-description', children: labels.emptyDescription })] }) : labels.empty })
|
|
26
|
+
: _jsx("ul", { className: 'hig-trade-rows', "aria-label": labels.title, children: trades.map(row) });
|
|
27
|
+
return _jsxs("section", { ...rest, className: `hig-trade-history-list${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction, stickyHeader: stickyHeader }), notice != null && notice !== false && _jsx("div", { className: 'hig-trade-notice', children: notice }), body, footer != null && footer !== false && _jsx("div", { className: 'hig-trade-footer', children: footer })] });
|
|
21
28
|
}
|
package/react/dist/blocks.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
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';
|
|
2
|
+
export { MarketRow, type MarketRowProps } from './blocks/market-row.js';
|
|
3
3
|
export { TradeEntry } from './blocks/trade-entry.js';
|
|
4
4
|
export { InstallCommand } from './blocks/install-command.js';
|
|
5
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';
|
|
6
|
+
export { AccountBlock, AssetBalanceRow, accountRows, accountSectionRows, accountSectionTotal, assetValue, type AccountBlockProps, type AccountAsset, type AccountSection, type AccountOrder, type AccountRowsOptions, type AssetArtwork, type AssetBalanceRowProps } from './blocks/account-block.js';
|
|
7
7
|
export { LanguageBlock, filterLanguages, type LanguageBlockProps, type LanguageOption } from './blocks/language-block.js';
|
|
8
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';
|
|
9
|
+
export { ManagePositionBlock, positionCorridor, type ManagePositionBlockProps, type ManagePositionBlockLabels, type ManagePositionBlockAction, type ManagePositionBlockSummary, type ManagePositionBlockFigure, type ManagePositionIcon } from './blocks/manage-position-block.js';
|
|
10
|
+
export { TargetBlock, targetLayout, targetFormat, targetPresets, targetUnits, type TargetBlockProps, type TargetBlockLabels, type TargetKind, type TargetUnit, type TargetPrice, type TargetPreset, type TargetUnitOption } from './blocks/target-block.js';
|
|
11
|
+
export { PositionBlock, type PositionBlockProps, type PositionBlockDetail, type PositionBlockFigure, type PositionBlockRow, type PositionBlockFlag, type PositionBlockFlagAction } from './blocks/position-block.js';
|
|
12
|
+
export { ProfileBlock, type ProfileBlockProps, type ProfileSection, type ProfileRow, type ProfileStatus, type ProfileAction, type ProfileFigure } from './blocks/profile-block.js';
|
|
13
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';
|
|
14
|
+
export { SoundHapticsBlock, soundLevel, type SoundHapticsBlockProps, type SoundSection, type SoundVolume, type SettingAction } from './blocks/sound-haptics-block.js';
|
|
15
15
|
export { SignalsBlock, type SignalsBlockProps, type SignalsGroup, type SignalsItem } from './blocks/signals-block.js';
|
|
16
16
|
export { NotificationsBlock, type NotificationsBlockProps, type NotificationsItem } from './blocks/notifications-block.js';
|
|
17
17
|
export { TradeHistoryListBlock, tradeHistorySide, type TradeHistoryListBlockProps, type TradeHistoryListLabels, type TradeHistoryItem } from './blocks/trade-history-list-block.js';
|
|
18
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';
|
|
19
|
+
export { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker, type FromPickerBlockProps, type ToPickerBlockProps, type FromPickerProps, type ToPickerProps, type PickerListProps, type PickerInputProps } from './blocks/pickers.js';
|
|
20
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';
|
package/react/dist/blocks.js
CHANGED
|
@@ -4,11 +4,11 @@ export { MarketRow } from './blocks/market-row.js';
|
|
|
4
4
|
export { TradeEntry } from './blocks/trade-entry.js';
|
|
5
5
|
export { InstallCommand } from './blocks/install-command.js';
|
|
6
6
|
export { MarketingHero } from './blocks/marketing-hero.js';
|
|
7
|
-
export { AccountBlock, AssetBalanceRow, accountRows, assetValue } from './blocks/account-block.js';
|
|
7
|
+
export { AccountBlock, AssetBalanceRow, accountRows, accountSectionRows, accountSectionTotal, assetValue } from './blocks/account-block.js';
|
|
8
8
|
export { LanguageBlock, filterLanguages } from './blocks/language-block.js';
|
|
9
9
|
export { TokenActionBlock, tokenActionLabel } from './blocks/token-action-block.js';
|
|
10
10
|
export { ManagePositionBlock, positionCorridor } from './blocks/manage-position-block.js';
|
|
11
|
-
export { TargetBlock, targetLayout, targetFormat } from './blocks/target-block.js';
|
|
11
|
+
export { TargetBlock, targetLayout, targetFormat, targetPresets, targetUnits } from './blocks/target-block.js';
|
|
12
12
|
export { PositionBlock } from './blocks/position-block.js';
|
|
13
13
|
export { ProfileBlock } from './blocks/profile-block.js';
|
|
14
14
|
export { RewardBlock, rewardProgress } from './blocks/reward-block.js';
|
package/react/dist/button.js
CHANGED
|
@@ -3,7 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef, useId, useRef } from 'react';
|
|
4
4
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
5
|
import { useHIG } from './provider.js';
|
|
6
|
-
|
|
6
|
+
function useButton({ intent = 'primary', busy = false, busyLabel, disabled, fullWidth, suppressFeedback, onClick, children, type = 'button', ...props }, ref, kind) {
|
|
7
|
+
// The provider puts its press layer on the context (see PressDecoration); calling it here keeps the layer out of a lone Button bundle.
|
|
7
8
|
const context = useHIG();
|
|
8
9
|
const id = useId();
|
|
9
10
|
const sequence = useRef(0);
|
|
@@ -14,7 +15,8 @@ export const Button = forwardRef(function Button({ intent = 'primary', busy = fa
|
|
|
14
15
|
context.feedback?.emit({ id: `${id}/${++sequence.current}`, source: id, intent: 'activate', origin: e.detail === 0 ? 'keyboard' : 'pointer' });
|
|
15
16
|
}
|
|
16
17
|
catch { /* Optional feedback cannot alter the action. */ }
|
|
17
|
-
} }, children: [busy && _jsx("span", { className: 'hig-button-spinner', "aria-hidden": 'true' }), children, busy && busyText ? _jsxs("span", { role: 'status', className: 'hig-busy hig-sr-only', children: [" \u00B7 ", busyText] }) : null] });
|
|
18
|
-
}
|
|
19
|
-
export const
|
|
18
|
+
} }, children: [busy && _jsx("span", { className: 'hig-button-spinner', "aria-hidden": 'true' }), children, busy && busyText ? _jsxs("span", { role: 'status', className: 'hig-busy hig-sr-only', children: [" \u00B7 ", busyText] }) : null, context.drawPress?.(kind, !!disabled || busy)] });
|
|
19
|
+
}
|
|
20
|
+
export const Button = forwardRef(function Button(props, ref) { return useButton(props, ref, 'button'); });
|
|
21
|
+
export const IconButton = forwardRef(function IconButton({ label, children, className, ...props }, ref) { return useButton({ ...props, className: `hig-icon-button ${className ?? ''}`, 'aria-label': label, children: _jsx("span", { "aria-hidden": 'true', children: children }) }, ref, 'icon-button'); });
|
|
20
22
|
export const Link = forwardRef(function Link(props, ref) { return _jsx("a", { ...props, ref: ref, className: `hig-link ${props.className ?? ''}` }); });
|