@bloxwap/hig 0.5.2 → 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} +19 -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 +12 -4
- package/native/dist/pickers.js +6 -2
- 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} +6 -2
- package/native/dist/{swap-panel.js → swap-panel-block.js} +4 -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 +4 -4
- 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 +6 -2
- 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/shared.d.ts +1 -0
- package/react/dist/{recipes → blocks}/swap/shared.js +1 -0
- package/react/dist/{recipes/swap-panel.d.ts → blocks/swap-panel-block.d.ts} +6 -2
- package/react/dist/{recipes/swap-panel.js → blocks/swap-panel-block.js} +3 -1
- 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 +270 -5
- package/tokens/README.md +1 -1
- package/native/dist/recipes.d.ts +0 -46
- 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}/swap/settings.js +0 -0
- /package/react/dist/{recipes → blocks}/trade-entry.d.ts +0 -0
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ import {Button} from '@bloxwap/hig/react/button';
|
|
|
21
21
|
| --- | --- |
|
|
22
22
|
| `@bloxwap/hig/tokens` | Tokens, `resolvePrimaryColor`, `./tokens/css`, `./tokens/manifest` ([README](tokens/README.md)) |
|
|
23
23
|
| `@bloxwap/hig/contracts` | Types, formatting, feedback, announcements and messages ([README](contracts/README.md)) |
|
|
24
|
-
| `@bloxwap/hig/react/*` | Web components,
|
|
24
|
+
| `@bloxwap/hig/react/*` | Web components, blocks, `./react/css` and `./react/css/base` ([README](react/README.md)) |
|
|
25
25
|
| `@bloxwap/hig/native/*` | React Native components ([README](native/README.md)) |
|
|
26
26
|
| `@bloxwap/hig/chart` | `PriceChart` and `chartTheme` for `@bloxwap/chart` ([README](chart/README.md)) |
|
|
27
27
|
| `@bloxwap/hig/feedback/*` | Opt-in web and native sound/haptic adapters ([README](feedback/README.md)) |
|
package/chart/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bloxwap/hig/chart
|
|
2
2
|
|
|
3
|
-
Version 0.
|
|
3
|
+
Version 0.6.0, an entry of `@bloxwap/hig`. The HIG adapter for [`@bloxwap/chart`](https://github.com/bloxwap/chart): `PriceChart` (a
|
|
4
4
|
`<figure>` with a required text `summary`, lazy-loading `@bloxwap/chart/react` inside `Suspense`) and
|
|
5
5
|
`chartTheme` (HIG token colors in sRGB for the canvas). Web only; React Native uses labeled readouts and lists
|
|
6
6
|
from `@bloxwap/hig/native/data`.
|
package/contracts/README.md
CHANGED
|
@@ -90,8 +90,6 @@ export interface HIGMessages {
|
|
|
90
90
|
confirmOrderDescription: (amount: string, asset: string) => string;
|
|
91
91
|
/** TradeEntry error alert title (web). */
|
|
92
92
|
orderUnavailable: string;
|
|
93
|
-
/** ActivityList empty text. */
|
|
94
|
-
noActivity: string;
|
|
95
93
|
/** StatusIndicator `online` state. */
|
|
96
94
|
statusOnline: string;
|
|
97
95
|
/** StatusIndicator `offline` state. */
|
|
@@ -180,7 +178,7 @@ export interface HIGMessages {
|
|
|
180
178
|
swapRecipient: string;
|
|
181
179
|
/** Accessible name of the recipient QR scan button. */
|
|
182
180
|
swapScan: string;
|
|
183
|
-
/** Accessible name of a wallet address that copies on press (WalletAddress, the
|
|
181
|
+
/** Accessible name of a wallet address that copies on press (WalletAddress, the SwapPanelBlock receive view); the address follows it. */
|
|
184
182
|
copyAddress: string;
|
|
185
183
|
/** Notice after a wallet address is copied. */
|
|
186
184
|
addressCopied: string;
|
|
@@ -194,6 +192,26 @@ export interface HIGMessages {
|
|
|
194
192
|
swapKeypad: string;
|
|
195
193
|
/** Accessible name of the keypad delete key. */
|
|
196
194
|
swapDelete: string;
|
|
195
|
+
/** AccountBlock: the default heading. */
|
|
196
|
+
account: string;
|
|
197
|
+
/** AccountBlock: the default label of the deposit action. */
|
|
198
|
+
deposit: string;
|
|
199
|
+
/** AccountBlock: accessible label of the total balance. */
|
|
200
|
+
accountBalance: string;
|
|
201
|
+
/** LanguageBlock: the default heading. */
|
|
202
|
+
language: string;
|
|
203
|
+
/** LanguageBlock: search placeholder and accessible name. */
|
|
204
|
+
searchLanguages: string;
|
|
205
|
+
/** AccountBlock: accessible name of the header button that shows the account address. */
|
|
206
|
+
showAddress: string;
|
|
207
|
+
/** ProfileBlock: accessible name of the control that edits the profile name. */
|
|
208
|
+
editName: string;
|
|
209
|
+
/** TokenActionBlock: built-in label of the `receive` action. */
|
|
210
|
+
receive: string;
|
|
211
|
+
/** TokenActionBlock: built-in label of the `stake` action. */
|
|
212
|
+
stake: string;
|
|
213
|
+
/** TokenActionBlock: built-in label of the `unstake` action. */
|
|
214
|
+
unstake: string;
|
|
197
215
|
}
|
|
198
216
|
export declare const close = "Close";
|
|
199
217
|
export declare const cancel = "Cancel";
|
|
@@ -236,7 +254,6 @@ export declare const reviewOrder = "Review order";
|
|
|
236
254
|
export declare const confirmOrder = "Confirm order";
|
|
237
255
|
export declare const confirmOrderDescription: (amount: string, asset: string) => string;
|
|
238
256
|
export declare const orderUnavailable = "Order unavailable";
|
|
239
|
-
export declare const noActivity = "No activity yet";
|
|
240
257
|
export declare const statusOnline = "online";
|
|
241
258
|
export declare const statusOffline = "offline";
|
|
242
259
|
export declare const statusStale = "stale";
|
|
@@ -288,6 +305,16 @@ export declare const qrCode = "QR code";
|
|
|
288
305
|
export declare const swapControlKey = "Ctrl";
|
|
289
306
|
export declare const swapKeypad = "Keypad";
|
|
290
307
|
export declare const swapDelete = "Delete";
|
|
308
|
+
export declare const account = "Account";
|
|
309
|
+
export declare const deposit = "Deposit";
|
|
310
|
+
export declare const accountBalance = "Total balance";
|
|
311
|
+
export declare const showAddress = "Show account address";
|
|
312
|
+
export declare const editName = "Edit name";
|
|
313
|
+
export declare const language = "Language";
|
|
314
|
+
export declare const searchLanguages = "Search languages";
|
|
315
|
+
export declare const receive = "Receive";
|
|
316
|
+
export declare const stake = "Stake";
|
|
317
|
+
export declare const unstake = "Unstake";
|
|
291
318
|
/** The complete English catalog. */
|
|
292
319
|
export declare const defaultMessages: Readonly<HIGMessages>;
|
|
293
320
|
/** Every message key, in documentation order. */
|
|
@@ -40,7 +40,6 @@ export const reviewOrder = 'Review order';
|
|
|
40
40
|
export const confirmOrder = 'Confirm order';
|
|
41
41
|
export const confirmOrderDescription = (amount, asset) => `Amount: ${amount} ${asset}. Verify the host-provided terms before submission.`;
|
|
42
42
|
export const orderUnavailable = 'Order unavailable';
|
|
43
|
-
export const noActivity = 'No activity yet';
|
|
44
43
|
export const statusOnline = 'online';
|
|
45
44
|
export const statusOffline = 'offline';
|
|
46
45
|
export const statusStale = 'stale';
|
|
@@ -92,8 +91,18 @@ export const qrCode = 'QR code';
|
|
|
92
91
|
export const swapControlKey = 'Ctrl';
|
|
93
92
|
export const swapKeypad = 'Keypad';
|
|
94
93
|
export const swapDelete = 'Delete';
|
|
94
|
+
export const account = 'Account';
|
|
95
|
+
export const deposit = 'Deposit';
|
|
96
|
+
export const accountBalance = 'Total balance';
|
|
97
|
+
export const showAddress = 'Show account address';
|
|
98
|
+
export const editName = 'Edit name';
|
|
99
|
+
export const language = 'Language';
|
|
100
|
+
export const searchLanguages = 'Search languages';
|
|
101
|
+
export const receive = 'Receive';
|
|
102
|
+
export const stake = 'Stake';
|
|
103
|
+
export const unstake = 'Unstake';
|
|
95
104
|
/** The complete English catalog. */
|
|
96
|
-
export const defaultMessages = { close, cancel, dismiss, dismissNotice, busy, notifications, loading, loadingContent, loadingItems, loadingChart, noItems, noRows, retry, loadMore, stale, required, breadcrumb, pagination, previous, next, pageOf, search, searching, noResults, resultCount, back, menuDescription, choose, chooseOne, inProgress, progressValue, copied, copyFailed, copyInstallCommand, reviewAssetOrder, amountInAsset, availableAmount, reviewOrder, confirmOrder, confirmOrderDescription, orderUnavailable,
|
|
105
|
+
export const defaultMessages = { close, cancel, dismiss, dismissNotice, busy, notifications, loading, loadingContent, loadingItems, loadingChart, noItems, noRows, retry, loadMore, stale, required, breadcrumb, pagination, previous, next, pageOf, search, searching, noResults, resultCount, back, menuDescription, choose, chooseOne, inProgress, progressValue, copied, copyFailed, copyInstallCommand, reviewAssetOrder, amountInAsset, availableAmount, reviewOrder, confirmOrder, confirmOrderDescription, orderUnavailable, statusOnline, statusOffline, statusStale, increase, decrease, swapFrom, swapTo, swapSelectToken, swapAmount, swapSwitchDenomination, swapFlip, swapActionSend, swapActionSwap, swapActionBridge, swapChooseToken, swapChooseDestination, swapEnterAmount, swapInsufficient, swapSendFromWallet, swapReset, swapSettings, swapMax, swapTest, swapSlippage, swapSlippageTitle, swapSlippageCustom, swapFee, swapFees, swapFeeTotal, swapDenomination, swapDollars, swapUnits, swapSearchTokens, swapChains, swapAllChains, swapHot, swapAllTokens, swapNoTokens, swapSelected, swapConnectWallet, swapDisconnect, swapGenerateAddress, swapRecipient, swapScan, copyAddress, addressCopied, tapToCopy, qrCode, swapControlKey, swapKeypad, swapDelete, account, deposit, accountBalance, showAddress, editName, language, searchLanguages, receive, stake, unstake };
|
|
97
106
|
/** Every message key, in documentation order. */
|
|
98
107
|
export const messageKeys = /* @__PURE__ */ Object.keys(defaultMessages);
|
|
99
108
|
/**
|
package/feedback/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bloxwap/hig/feedback
|
|
2
2
|
|
|
3
|
-
Version 0.
|
|
3
|
+
Version 0.6.0, an entry of `@bloxwap/hig`. Root contract imports no React, DOM, RN, audio or device API. Use independent web/native entries and opt in to each channel. Successful API invocation never certifies physical output. See docs/feedback for timing, storage, capability and device verification.
|
|
4
4
|
|
|
5
5
|
`createWebSoundAdapter` passes a per-adapter abort signal to SFX. The signal-aware engine cancels that root's active voices while other roots and host-owned playback continue. The shared default engine remains reference-counted.
|
|
6
6
|
|
package/native/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bloxwap/hig/native
|
|
2
2
|
|
|
3
|
-
Version 0.
|
|
3
|
+
Version 0.6.0, an entry of `@bloxwap/hig`. Import individual entries; see docs/components for platform and accessibility contracts.
|
|
4
4
|
|
|
5
5
|
Set a brand accent with `<HIGProvider primaryColor='#ff0000'>` from
|
|
6
6
|
`@bloxwap/hig/native/provider`. It accepts opaque sRGB hex (`#RGB` or `#RRGGBB`),
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type AssetArtwork } from './asset-balance-row.js';
|
|
3
|
+
export { AssetBalanceRow, type AssetArtwork, type AssetBalanceRowProps } from './asset-balance-row.js';
|
|
4
|
+
/** One holding in the account. The host supplies every value; HIG sorts, formats and lays it out. */
|
|
5
|
+
export interface AccountAsset {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
symbol: string;
|
|
9
|
+
icon?: AssetArtwork;
|
|
10
|
+
/** Holding in token units. */
|
|
11
|
+
balance?: number | null;
|
|
12
|
+
/** USD per unit. */
|
|
13
|
+
price?: number | null;
|
|
14
|
+
/** USD value; defaults to balance × price. */
|
|
15
|
+
value?: number | null;
|
|
16
|
+
}
|
|
17
|
+
export interface AccountBlockProps {
|
|
18
|
+
/** Defaults to the localized "Account". */
|
|
19
|
+
title?: string;
|
|
20
|
+
/** Shows Back on the leading edge of the header. */
|
|
21
|
+
onBack?: () => void;
|
|
22
|
+
/** Shows a QR button on the trailing edge of the header, above the deposit action. The host shows the account address, for example with WalletAddress. */
|
|
23
|
+
onShowAddress?: () => void;
|
|
24
|
+
/** A control on the trailing edge of the header, usually an IconButton. Replaces the QR button. */
|
|
25
|
+
headerAction?: React.ReactNode;
|
|
26
|
+
/** Total in dollars; defaults to the sum of the asset values. `null` shows it as unknown. */
|
|
27
|
+
balance?: number | null;
|
|
28
|
+
assets: readonly AccountAsset[];
|
|
29
|
+
/** Symbol of the asset pinned first; default 'USDC'. */
|
|
30
|
+
pinnedSymbol?: string;
|
|
31
|
+
/** Shows the deposit action beside the total. */
|
|
32
|
+
onDeposit?: () => void;
|
|
33
|
+
depositLabel?: string;
|
|
34
|
+
/** Makes each row a button. */
|
|
35
|
+
onAssetSelect?: (asset: AccountAsset) => void;
|
|
36
|
+
testID?: string;
|
|
37
|
+
}
|
|
38
|
+
/** An asset's dollar value: its own `value`, else balance × price, else unknown. */
|
|
39
|
+
export declare const assetValue: (asset: AccountAsset) => number | null;
|
|
40
|
+
/** The pinned asset (a zero placeholder when the account does not hold it) and the rest by dollar value, largest first, unknown values last, ties by name. */
|
|
41
|
+
export declare function accountRows(assets: readonly AccountAsset[], pinnedSymbol?: string): {
|
|
42
|
+
pinned: AccountAsset;
|
|
43
|
+
rest: AccountAsset[];
|
|
44
|
+
};
|
|
45
|
+
/** The account as one screen: a header, the total with the deposit action, the pinned asset, then every other holding by value. */
|
|
46
|
+
export declare function AccountBlock({ title, onBack, onShowAddress, headerAction, balance, assets, pinnedSymbol, onDeposit, depositLabel, onAssetSelect, testID }: AccountBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { useColors, useHIG, useMessages } from './provider.js';
|
|
4
|
+
import { Text } from './surface.js';
|
|
5
|
+
import { Button, IconButton } from './button.js';
|
|
6
|
+
import { ChevronIcon, QrIcon } from './icons.js';
|
|
7
|
+
import { AnimatedNumberReadout } from './animated-number.js';
|
|
8
|
+
import { AssetBalanceRow } from './asset-balance-row.js';
|
|
9
|
+
export { AssetBalanceRow } from './asset-balance-row.js';
|
|
10
|
+
const usdc = 'USDC', usdCoin = 'USD Coin';
|
|
11
|
+
const usd = { style: 'currency', currency: 'USD' };
|
|
12
|
+
/** An asset's dollar value: its own `value`, else balance × price, else unknown. */
|
|
13
|
+
export const assetValue = (asset) => asset.value !== undefined ? asset.value : asset.balance != null && asset.price != null ? asset.balance * asset.price : null;
|
|
14
|
+
/** The pinned asset (a zero placeholder when the account does not hold it) and the rest by dollar value, largest first, unknown values last, ties by name. */
|
|
15
|
+
export function accountRows(assets, pinnedSymbol = usdc) {
|
|
16
|
+
const wanted = pinnedSymbol.toLowerCase(), found = assets.find(asset => asset.symbol.toLowerCase() === wanted);
|
|
17
|
+
const pinned = found ?? { id: pinnedSymbol, name: pinnedSymbol === usdc ? usdCoin : pinnedSymbol, symbol: pinnedSymbol, balance: 0, value: 0 };
|
|
18
|
+
const rest = assets.filter(asset => asset !== found).sort((a, b) => { const x = assetValue(a), y = assetValue(b); return x === y ? a.name.localeCompare(b.name) : x === null ? 1 : y === null ? -1 : y - x || a.name.localeCompare(b.name); });
|
|
19
|
+
return { pinned, rest };
|
|
20
|
+
}
|
|
21
|
+
/** The account as one screen: a header, the total with the deposit action, the pinned asset, then every other holding by value. */
|
|
22
|
+
export function AccountBlock({ title, onBack, onShowAddress, headerAction, balance, assets, pinnedSymbol = usdc, onDeposit, depositLabel, onAssetSelect, testID }) {
|
|
23
|
+
const colors = useColors(), t = useMessages(), { direction } = useHIG();
|
|
24
|
+
const { pinned, rest } = accountRows(assets, pinnedSymbol);
|
|
25
|
+
const total = balance !== undefined ? balance : assets.reduce((sum, asset) => sum + (assetValue(asset) ?? 0), 0);
|
|
26
|
+
const select = (asset) => onAssetSelect ? () => onAssetSelect(asset) : undefined;
|
|
27
|
+
return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [_jsxs(View, { testID: 'account-header', style: { flexDirection: 'row', alignItems: 'center', minHeight: 44 }, children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onBack ? _jsx(IconButton, { intent: 'ghost', label: t.back, suppressFeedback: true, testID: 'account-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'account-title', accessibilityRole: 'header', numberOfLines: 1, style: { flex: 1, textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: colors.text }, children: title ?? t.account }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: headerAction ?? (onShowAddress ? _jsx(IconButton, { intent: 'ghost', label: t.showAddress, testID: 'account-address', onPress: onShowAddress, children: _jsx(QrIcon, { color: colors.text }) }) : null) })] }), _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12, marginTop: 8 }, children: [_jsx(View, { style: { flexShrink: 1 }, children: _jsx(AnimatedNumberReadout, { value: total, options: usd, label: t.accountBalance, testID: 'account-balance', style: { fontSize: 32, lineHeight: 40, fontWeight: '600' } }) }), onDeposit ? _jsx(Button, { testID: 'account-deposit', onPress: onDeposit, children: depositLabel ?? t.deposit }) : null] }), _jsxs(View, { testID: 'account-assets', style: { gap: 8, marginTop: 16 }, children: [_jsx(AssetBalanceRow, { testID: `account-asset-${pinned.id}`, name: pinned.name, symbol: pinned.symbol, icon: pinned.icon, value: assetValue(pinned), onSelect: select(pinned) }, pinned.id), rest.map(asset => _jsx(AssetBalanceRow, { testID: `account-asset-${asset.id}`, name: asset.name, symbol: asset.symbol, icon: asset.icon, value: assetValue(asset), balance: asset.balance ?? null, onSelect: select(asset) }, asset.id))] })] });
|
|
28
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** Asset artwork: an image URL, or the host's own element. */
|
|
3
|
+
export type AssetArtwork = string | React.ReactElement;
|
|
4
|
+
export interface AssetBalanceRowProps {
|
|
5
|
+
name: string;
|
|
6
|
+
symbol: string;
|
|
7
|
+
/** Without artwork the avatar shows the first three letters of the symbol. */
|
|
8
|
+
icon?: AssetArtwork;
|
|
9
|
+
/** Dollar value of the holding. */
|
|
10
|
+
value?: number | null;
|
|
11
|
+
/** Holding in token units; omit to show the value alone. */
|
|
12
|
+
balance?: number | null;
|
|
13
|
+
/** Format of the units line; default `{maximumFractionDigits:6}`. */
|
|
14
|
+
balanceOptions?: Intl.NumberFormatOptions;
|
|
15
|
+
/** Makes the row a button. */
|
|
16
|
+
onSelect?: () => void;
|
|
17
|
+
testID?: string;
|
|
18
|
+
}
|
|
19
|
+
/** One holding as a capsule row: a round avatar, the asset's name over its symbol, and its dollar value over its units. The avatar is padded equally on every side, so the capsule end is concentric with it, and both numbers update place by place. */
|
|
20
|
+
export declare function AssetBalanceRow({ name, symbol, icon, value, balance, balanceOptions, onSelect, testID }: AssetBalanceRowProps): React.JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Image, Pressable, View } from 'react-native';
|
|
3
|
+
import { useColors, useFills, useHIG } from './provider.js';
|
|
4
|
+
import { Text } from './surface.js';
|
|
5
|
+
import { AnimatedNumberReadout } from './animated-number.js';
|
|
6
|
+
import { formatNumberReadout } from './animated-number-model.js';
|
|
7
|
+
const usd = { style: 'currency', currency: 'USD' };
|
|
8
|
+
const units = { maximumFractionDigits: 6 };
|
|
9
|
+
const avatar = 40;
|
|
10
|
+
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
11
|
+
/** One holding as a capsule row: a round avatar, the asset's name over its symbol, and its dollar value over its units. The avatar is padded equally on every side, so the capsule end is concentric with it, and both numbers update place by place. */
|
|
12
|
+
export function AssetBalanceRow({ name, symbol, icon, value, balance, balanceOptions = units, onSelect, testID }) {
|
|
13
|
+
const colors = useColors(), fills = useFills(), { locale } = useHIG();
|
|
14
|
+
const hasUnits = balance !== undefined;
|
|
15
|
+
const label = [name, symbol, formatNumberReadout(value, locale, usd).text, hasUnits ? formatNumberReadout(balance, locale, balanceOptions).text : null].filter(Boolean).join(', ');
|
|
16
|
+
const shape = { width: avatar, height: avatar, borderRadius: avatar / 2, backgroundColor: fills.raised, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' };
|
|
17
|
+
const art = typeof icon === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: icon }, style: shape }) : _jsx(View, { style: shape, children: icon ?? _jsx(Text, { accessible: false, maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: symbol.slice(0, 3) }) });
|
|
18
|
+
const row = (pressed) => ({ flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 56, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 28, backgroundColor: pressed ? fills.raised : fills.well });
|
|
19
|
+
const content = _jsxs(_Fragment, { children: [_jsx(View, { ...hidden, children: art }), _jsxs(View, { ...hidden, style: { flex: 1, flexShrink: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.text }, children: name }), _jsx(Text, { numberOfLines: 1, style: { fontSize: 14, lineHeight: 20, color: colors.muted }, children: symbol })] }), _jsxs(View, { ...hidden, style: { alignItems: 'flex-end', justifyContent: 'center' }, children: [_jsx(AnimatedNumberReadout, { value: value, options: usd, testID: testID ? `${testID}-value` : undefined, style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }), hasUnits ? _jsx(AnimatedNumberReadout, { value: balance, options: balanceOptions, tone: 'muted', testID: testID ? `${testID}-balance` : undefined, style: { fontSize: 14, lineHeight: 20 } }) : null] })] });
|
|
20
|
+
return onSelect ? _jsx(Pressable, { testID: testID, accessibilityRole: 'button', accessibilityLabel: label, onPress: onSelect, style: ({ pressed }) => row(pressed), children: content }) : _jsx(View, { testID: testID, accessible: true, accessibilityLabel: label, style: row(false), children: content });
|
|
21
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** Colour roles a segment can take. They follow the provider's colour space and market colours as those roles do. */
|
|
3
|
+
export type BarMarkTone = 'positive' | 'info' | 'warning' | 'negative' | 'muted' | 'faint';
|
|
4
|
+
export interface BarMarkElement {
|
|
5
|
+
/** Stable key and testID suffix; the index is used when omitted. */
|
|
6
|
+
id?: string;
|
|
7
|
+
label: string;
|
|
8
|
+
/** Any unit, as long as every element uses the same one. Negative and non-finite values count as 0. */
|
|
9
|
+
value: number;
|
|
10
|
+
/** Defaults to `barMarkTones[index % 6]`. */
|
|
11
|
+
tone?: BarMarkTone;
|
|
12
|
+
/** A host colour for this segment; wins over `tone`. */
|
|
13
|
+
color?: string;
|
|
14
|
+
/** Host-formatted amount shown after the label in the legend, such as `12.4 GB`. */
|
|
15
|
+
detail?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface BarMarkProps {
|
|
18
|
+
title: string;
|
|
19
|
+
/** Trailing text on the title row, such as `59.2 GB of 64 GB`. A string is drawn muted; an element is rendered as given. */
|
|
20
|
+
description?: React.ReactNode;
|
|
21
|
+
elements: readonly BarMarkElement[];
|
|
22
|
+
/** The whole the bar measures against. When it is larger than the sum of the values the rest is the empty track. */
|
|
23
|
+
total?: number;
|
|
24
|
+
/** `false` hides the legend; the card then reads the elements as one label. */
|
|
25
|
+
legend?: boolean;
|
|
26
|
+
/** `small` draws a 12 unit bar for a secondary breakdown; the default is 24. */
|
|
27
|
+
size?: 'default' | 'small';
|
|
28
|
+
/** Set false to draw no card: no surface fill, padding or radius. The title row, bar and legend keep their spacing. Default `true`. */
|
|
29
|
+
surface?: boolean;
|
|
30
|
+
testID?: string;
|
|
31
|
+
}
|
|
32
|
+
/** The order segments take their colour in when an element names neither `tone` nor `color`. */
|
|
33
|
+
export declare const barMarkTones: readonly BarMarkTone[];
|
|
34
|
+
/** Each element's clamped value and its share of the whole, plus the unfilled remainder in the same unit. */
|
|
35
|
+
export declare function barMarkShares(elements: readonly BarMarkElement[], total?: number): {
|
|
36
|
+
values: number[];
|
|
37
|
+
shares: number[];
|
|
38
|
+
rest: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* One horizontally stacked bar on a card: the title leads and the description trails, the bar splits into a segment per
|
|
42
|
+
* element in proportion to its value, and a legend names each colour. The bar is decorative; each legend item reads its
|
|
43
|
+
* label, detail and share. Layout follows the provider's direction.
|
|
44
|
+
*/
|
|
45
|
+
export declare function BarMark({ title, description, elements, total, legend, size, surface, testID }: BarMarkProps): React.JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
4
|
+
import { useColors, useFills, useHIG } from './provider.js';
|
|
5
|
+
import { Surface, Text } from './surface.js';
|
|
6
|
+
/** The order segments take their colour in when an element names neither `tone` nor `color`. */
|
|
7
|
+
export const barMarkTones = ['positive', 'info', 'warning', 'negative', 'muted', 'faint'];
|
|
8
|
+
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
9
|
+
/** Each element's clamped value and its share of the whole, plus the unfilled remainder in the same unit. */
|
|
10
|
+
export function barMarkShares(elements, total) {
|
|
11
|
+
const values = elements.map(element => Number.isFinite(element.value) && element.value > 0 ? element.value : 0), sum = values.reduce((a, b) => a + b, 0);
|
|
12
|
+
const whole = Math.max(typeof total === 'number' && Number.isFinite(total) ? total : sum, sum);
|
|
13
|
+
return { values, shares: values.map(value => whole > 0 ? value / whole : 0), rest: whole > 0 ? whole - sum : 1 };
|
|
14
|
+
}
|
|
15
|
+
// A component of its own so the track reads the raised fill of whatever it sits on: one step above the card inside the Surface, one step above the page without it.
|
|
16
|
+
function Bar({ elements, values, rest, colors, small, testID }) {
|
|
17
|
+
const track = useFills().raised;
|
|
18
|
+
return _jsxs(View, { ...hidden, testID: testID ? `${testID}-bar` : undefined, style: { flexDirection: 'row', height: small ? 12 : 24, borderRadius: small ? 6 : 8, overflow: 'hidden', gap: 2 }, children: [elements.map((element, index) => values[index] > 0 ? _jsx(View, { testID: testID ? `${testID}-segment-${element.id ?? index}` : undefined, style: { flexGrow: values[index], flexShrink: 1, flexBasis: 0, minWidth: 3, backgroundColor: colors[index] } }, element.id ?? index) : null), rest > 0 ? _jsx(View, { testID: testID ? `${testID}-track` : undefined, style: { flexGrow: rest, flexShrink: 1, flexBasis: 0, backgroundColor: track } }) : null] });
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* One horizontally stacked bar on a card: the title leads and the description trails, the bar splits into a segment per
|
|
22
|
+
* element in proportion to its value, and a legend names each colour. The bar is decorative; each legend item reads its
|
|
23
|
+
* label, detail and share. Layout follows the provider's direction.
|
|
24
|
+
*/
|
|
25
|
+
export function BarMark({ title, description, elements, total, legend = true, size = 'default', surface = true, testID }) {
|
|
26
|
+
const { locale, direction } = useHIG();
|
|
27
|
+
const palette = useColors();
|
|
28
|
+
const { values, shares, rest } = barMarkShares(elements, total);
|
|
29
|
+
const colors = elements.map((element, index) => element.color ?? palette[element.tone ?? barMarkTones[index % barMarkTones.length]]);
|
|
30
|
+
const reading = (element, index) => [element.label, element.detail, formatNumber(shares[index], locale, { style: 'percent', maximumFractionDigits: 1 })].filter(Boolean).join(', ');
|
|
31
|
+
const group = legend ? {} : { accessible: true, accessibilityLabel: [title, ...elements.map(reading)].join(', ') };
|
|
32
|
+
const content = _jsxs(_Fragment, { children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', justifyContent: 'space-between', gap: 12 }, children: [_jsx(Text, { style: { fontSize: 16, lineHeight: 24, fontWeight: '600', flexShrink: 1 }, children: title }), description == null || description === false ? null : typeof description === 'string' || typeof description === 'number' ? _jsx(Text, { style: { color: palette.muted, fontSize: 14, lineHeight: 21, flexShrink: 1 }, children: description }) : description] }), _jsx(Bar, { elements: elements, values: values, rest: rest, colors: colors, small: size === 'small', testID: testID }), legend ? _jsx(View, { style: { flexDirection: 'row', flexWrap: 'wrap', columnGap: 16, rowGap: 8 }, children: elements.map((element, index) => _jsxs(View, { accessible: true, accessibilityLabel: reading(element, index), testID: testID ? `${testID}-legend-${element.id ?? index}` : undefined, style: { flexDirection: 'row', alignItems: 'center', gap: 6 }, children: [_jsx(View, { style: { width: 8, height: 8, borderRadius: 4, backgroundColor: colors[index] } }), _jsx(Text, { style: { color: palette.muted, fontSize: 14, lineHeight: 21 }, children: element.label }), element.detail ? _jsx(Text, { style: { color: palette.faint, fontSize: 14, lineHeight: 21 }, children: element.detail }) : null] }, element.id ?? index)) }) : null] });
|
|
33
|
+
return surface ? _jsx(Surface, { testID: testID, style: { gap: 12 }, ...group, children: content }) : _jsx(View, { testID: testID, style: { direction, gap: 12, minWidth: 0 }, ...group, children: content });
|
|
34
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type BarPnlSide = 'long' | 'short';
|
|
3
|
+
export type BarPnlResult = 'profit' | 'loss' | 'flat';
|
|
4
|
+
export type BarPnlKind = 'liquidation' | 'mark' | 'entry';
|
|
5
|
+
export interface BarPnlProps {
|
|
6
|
+
/** Price the position was opened at. */
|
|
7
|
+
entry: number;
|
|
8
|
+
/** Current mark price. `null` or omitted reads as unknown and draws no profit or loss. */
|
|
9
|
+
mark?: number | null;
|
|
10
|
+
/** Liquidation price. Omit it, or pass `null`, for a position that cannot be liquidated. */
|
|
11
|
+
liquidation?: number | null;
|
|
12
|
+
/** Direction of the position. Defaults to `long` when the liquidation price is below entry (or unknown) and `short` when it is above. */
|
|
13
|
+
side?: BarPnlSide;
|
|
14
|
+
/** Host text for the three prices, for example `{liquidation:'Liquidation',mark:'Mark',entry:'Entry'}`. HIG ships no trading terms of its own. */
|
|
15
|
+
labels: Record<BarPnlKind, string>;
|
|
16
|
+
/** Heading on the leading edge above the bar, such as `BTC Long 10×`. */
|
|
17
|
+
title?: string;
|
|
18
|
+
/** Trailing text on the title row, such as the profit or loss in dollars. A string is drawn muted; an element is rendered as given. */
|
|
19
|
+
description?: React.ReactNode;
|
|
20
|
+
/** Format of the three prices. Defaults to US dollars. */
|
|
21
|
+
priceOptions?: Intl.NumberFormatOptions;
|
|
22
|
+
/** Shortens the three prices for narrow screens: `$64,700` for `$64,700.00`, `$142.96`, `$0.4821`. Trailing zeros are dropped. Default `false`. */
|
|
23
|
+
compact?: boolean;
|
|
24
|
+
/** Scales the bar to the prices themselves, so the stretch from entry to mark fills it. For a finished trade, where the move is the whole story. Default `false`. */
|
|
25
|
+
fit?: boolean;
|
|
26
|
+
/** Set false to draw no card: no surface fill, padding or radius. The title row, bar and readouts keep their spacing. Default `true`. */
|
|
27
|
+
surface?: boolean;
|
|
28
|
+
testID?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Price format for `compact`: no fraction at 1,000 and above, at most two fraction digits from 1, and four significant digits below 1, with trailing zeros dropped. Host `priceOptions` (such as the currency) are kept. */
|
|
31
|
+
export declare function barPnlCompactOptions(value: number | null | undefined, base?: Intl.NumberFormatOptions): Intl.NumberFormatOptions;
|
|
32
|
+
/**
|
|
33
|
+
* Where each price sits on the bar, as a fraction of its width from the low-price edge, the readouts in price order, and
|
|
34
|
+
* whether the position is in profit. With a liquidation price the bar runs from it to the same distance on the other side
|
|
35
|
+
* of entry, so entry sits in the middle; a mark beyond either end stretches the bar. Without one the bar is centred on entry.
|
|
36
|
+
*/
|
|
37
|
+
export declare function barPnlLayout({ entry, mark, liquidation, side, fit }: {
|
|
38
|
+
entry: number;
|
|
39
|
+
mark?: number | null;
|
|
40
|
+
liquidation?: number | null;
|
|
41
|
+
side?: BarPnlSide;
|
|
42
|
+
fit?: boolean;
|
|
43
|
+
}): {
|
|
44
|
+
side: BarPnlSide;
|
|
45
|
+
result: BarPnlResult;
|
|
46
|
+
positions: Partial<Record<BarPnlKind, number>>;
|
|
47
|
+
order: BarPnlKind[];
|
|
48
|
+
};
|
|
49
|
+
/** A position's profit or loss as one bar: the stretch between entry and mark is filled solid in the result colour, a tick marks each price, and the liquidation, mark and entry prices read under the bar in price order, so mark and entry trade places as the position moves. The bar is decorative; each readout reads its label and price. */
|
|
50
|
+
export declare function BarPnl({ entry, mark, liquidation, side, labels, title, description, priceOptions, compact, fit, surface, testID }: BarPnlProps): React.JSX.Element;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { useColors, useFills, useHIG } from './provider.js';
|
|
4
|
+
import { Surface, Text } from './surface.js';
|
|
5
|
+
import { AnimatedNumberReadout } from './animated-number.js';
|
|
6
|
+
import { formatNumberReadout } from './animated-number-model.js';
|
|
7
|
+
const usd = { style: 'currency', currency: 'USD' };
|
|
8
|
+
const finite = (value) => typeof value === 'number' && Number.isFinite(value);
|
|
9
|
+
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
10
|
+
/** Price format for `compact`: no fraction at 1,000 and above, at most two fraction digits from 1, and four significant digits below 1, with trailing zeros dropped. Host `priceOptions` (such as the currency) are kept. */
|
|
11
|
+
export function barPnlCompactOptions(value, base = usd) {
|
|
12
|
+
const size = finite(value) ? Math.abs(value) : 0;
|
|
13
|
+
return size > 0 && size < 1 ? { ...base, minimumFractionDigits: undefined, maximumFractionDigits: undefined, maximumSignificantDigits: 4 } : { ...base, minimumFractionDigits: 0, maximumFractionDigits: size >= 1000 ? 0 : 2 };
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Where each price sits on the bar, as a fraction of its width from the low-price edge, the readouts in price order, and
|
|
17
|
+
* whether the position is in profit. With a liquidation price the bar runs from it to the same distance on the other side
|
|
18
|
+
* of entry, so entry sits in the middle; a mark beyond either end stretches the bar. Without one the bar is centred on entry.
|
|
19
|
+
*/
|
|
20
|
+
export function barPnlLayout({ entry, mark, liquidation, side, fit }) {
|
|
21
|
+
const liq = finite(liquidation) ? liquidation : null;
|
|
22
|
+
const direction = side ?? (liq !== null && liq > entry ? 'short' : 'long');
|
|
23
|
+
const result = !finite(entry) || !finite(mark) || mark === entry ? 'flat' : (mark > entry) === (direction === 'long') ? 'profit' : 'loss';
|
|
24
|
+
if (!finite(entry))
|
|
25
|
+
return { side: direction, result, positions: {}, order: [] };
|
|
26
|
+
const price = finite(mark) ? mark : entry;
|
|
27
|
+
const reach = liq !== null ? Math.abs(entry - liq) : Math.max(Math.abs(price - entry) * 2, Math.abs(entry) * 0.01, Number.MIN_VALUE);
|
|
28
|
+
// `fit` scales the bar to the prices themselves, so the stretch from entry to mark fills it.
|
|
29
|
+
const points = liq !== null ? [entry, price, liq] : [entry, price];
|
|
30
|
+
const low = fit ? Math.min(...points) : Math.min(entry - reach, price), high = fit ? Math.max(...points) : Math.max(entry + reach, price), span = high - low;
|
|
31
|
+
const at = (value) => span > 0 ? Math.min(1, Math.max(0, (value - low) / span)) : 0.5;
|
|
32
|
+
const positions = { entry: at(entry), mark: at(price) };
|
|
33
|
+
if (liq !== null)
|
|
34
|
+
positions.liquidation = at(liq);
|
|
35
|
+
// Ties keep liquidation outermost and put mark on the side it would move to next.
|
|
36
|
+
const rank = { liquidation: direction === 'long' ? 0 : 2, entry: 1, mark: direction === 'long' ? (result === 'loss' ? 0.5 : 1.5) : (result === 'loss' ? 1.5 : 0.5) };
|
|
37
|
+
const values = { liquidation: liq ?? 0, entry, mark: price };
|
|
38
|
+
const order = Object.keys(positions).sort((a, b) => values[a] - values[b] || rank[a] - rank[b]);
|
|
39
|
+
return { side: direction, result, positions, order };
|
|
40
|
+
}
|
|
41
|
+
/** A position's profit or loss as one bar: the stretch between entry and mark is filled solid in the result colour, a tick marks each price, and the liquidation, mark and entry prices read under the bar in price order, so mark and entry trade places as the position moves. The bar is decorative; each readout reads its label and price. */
|
|
42
|
+
export function BarPnl({ entry, mark, liquidation, side, labels, title, description, priceOptions = usd, compact = false, fit = false, surface = true, testID }) {
|
|
43
|
+
const colors = useColors(), { locale, direction } = useHIG();
|
|
44
|
+
const { result, positions, order } = barPnlLayout({ entry, mark, liquidation, side, fit });
|
|
45
|
+
const tone = result === 'profit' ? colors.positive : result === 'loss' ? colors.negative : colors.muted;
|
|
46
|
+
const from = Math.min(positions.entry ?? 0.5, positions.mark ?? 0.5), to = Math.max(positions.entry ?? 0.5, positions.mark ?? 0.5);
|
|
47
|
+
const markLeads = (positions.mark ?? 0) < (positions.entry ?? 0);
|
|
48
|
+
const values = { liquidation, mark, entry };
|
|
49
|
+
const format = (kind) => compact ? barPnlCompactOptions(values[kind], priceOptions) : priceOptions;
|
|
50
|
+
const align = (index) => order.length > 1 && index === order.length - 1 ? 'flex-end' : order.length === 3 && index === 1 ? 'center' : 'flex-start';
|
|
51
|
+
const content = _jsxs(_Fragment, { children: [title || description != null ? _jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', justifyContent: 'space-between', gap: 12 }, children: [title ? _jsx(Text, { accessibilityRole: 'header', style: { fontSize: 16, lineHeight: 24, fontWeight: '600', flexShrink: 1 }, children: title }) : _jsx(View, {}), description == null || description === false ? null : typeof description === 'string' || typeof description === 'number' ? _jsx(Text, { style: { color: colors.muted, fontSize: 14, lineHeight: 21, flexShrink: 1 }, children: description }) : description] }) : null, _jsx(Bar, { from: from, to: to, markLeads: markLeads, tone: tone, liquidation: positions.liquidation, testID: testID }), _jsx(View, { style: { flexDirection: 'row', justifyContent: 'space-between', gap: 12 }, children: order.map((kind, index) => _jsxs(View, { accessible: true, accessibilityLabel: `${labels[kind]}, ${formatNumberReadout(values[kind], locale, format(kind)).text}`, testID: testID ? `${testID}-${kind}` : undefined, style: { alignItems: align(index), flexShrink: 1, minWidth: 0 }, children: [_jsx(View, { ...hidden, children: _jsx(AnimatedNumberReadout, { value: values[kind], options: format(kind), tone: kind === 'liquidation' ? 'negative' : kind === 'mark' && result !== 'flat' ? (result === 'profit' ? 'positive' : 'negative') : 'text', style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) }), _jsx(Text, { ...hidden, numberOfLines: 1, style: { color: colors.muted, fontSize: 12, lineHeight: 16 }, children: labels[kind] })] }, kind)) })] });
|
|
52
|
+
return surface ? _jsx(Surface, { testID: testID, style: { gap: 12 }, children: content }) : _jsx(View, { testID: testID, style: { direction, gap: 12, minWidth: 0 }, children: content });
|
|
53
|
+
}
|
|
54
|
+
// Inside the Surface, so the track takes the fill that sits one step above the card.
|
|
55
|
+
function Bar({ from, to, markLeads, tone, liquidation, testID }) {
|
|
56
|
+
const colors = useColors(), track = useFills().raised;
|
|
57
|
+
const part = (grow) => ({ flexGrow: grow, flexShrink: 1, flexBasis: 0, backgroundColor: track });
|
|
58
|
+
return _jsxs(View, { ...hidden, testID: testID ? `${testID}-bar` : undefined, style: { flexDirection: 'row', height: 24, borderRadius: 8, overflow: 'hidden' }, children: [_jsx(View, { style: part(from) }), _jsx(View, { testID: testID ? `${testID}-move` : undefined, style: { flexGrow: to - from, flexShrink: 1, flexBasis: 0, minWidth: 6, backgroundColor: tone, borderStartWidth: 3, borderEndWidth: 3, borderStartColor: markLeads ? tone : colors.text, borderEndColor: markLeads ? colors.text : tone } }), _jsx(View, { style: part(1 - to) }), liquidation === undefined ? null : _jsx(View, { testID: testID ? `${testID}-liquidation-tick` : undefined, style: { position: 'absolute', top: 0, bottom: 0, width: 3, start: `${liquidation * 100}%`, marginStart: liquidation <= 0 ? 0 : liquidation >= 1 ? -3 : -1.5, backgroundColor: colors.negative } })] });
|
|
59
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function MarketRow({ symbol, name, price, change, onSelect }: {
|
|
3
|
+
symbol: string;
|
|
4
|
+
name: string;
|
|
5
|
+
price: number | null;
|
|
6
|
+
change: number | null;
|
|
7
|
+
onSelect: () => void;
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
export declare function TradeEntry({ asset, amount, onAmountChange, onConfirm, busy, error, available }: {
|
|
10
|
+
asset: string;
|
|
11
|
+
amount: string;
|
|
12
|
+
onAmountChange: (v: string) => void;
|
|
13
|
+
onConfirm: () => void;
|
|
14
|
+
busy?: boolean;
|
|
15
|
+
error?: string;
|
|
16
|
+
available: string;
|
|
17
|
+
}): React.JSX.Element;
|
|
18
|
+
/** A copy outcome shows as a transient toast capsule (about 4s, dismissible) and is announced the way Toast announces any notice. */
|
|
19
|
+
export declare function InstallCommand({ command, onCopy }: {
|
|
20
|
+
command: string;
|
|
21
|
+
onCopy: () => Promise<void> | void;
|
|
22
|
+
}): React.JSX.Element;
|
|
23
|
+
export declare function MarketingHero({ title, description, href, cta }: {
|
|
24
|
+
title: string;
|
|
25
|
+
description: string;
|
|
26
|
+
href: string;
|
|
27
|
+
cta: string;
|
|
28
|
+
}): React.JSX.Element;
|
|
29
|
+
export { AccountBlock, accountRows, assetValue, AssetBalanceRow, type AccountBlockProps, type AccountAsset, type AssetArtwork, type AssetBalanceRowProps } from './account-block.js';
|
|
30
|
+
export { LanguageBlock, filterLanguages, type LanguageBlockProps, type LanguageOption } from './language-block.js';
|
|
31
|
+
export { TokenActionBlock, tokenActionLabel, type TokenActionBlockProps, type TokenAction, type TokenActionId } from './token-action-block.js';
|
|
32
|
+
export { ManagePositionBlock, positionCorridor, type ManagePositionBlockProps, type ManagePositionBlockLabels, type ManagePositionBlockAction, type ManagePositionBlockSummary } from './manage-position-block.js';
|
|
33
|
+
export { TradeHistoryListBlock, tradeHistorySide, type TradeHistoryListBlockProps, type TradeHistoryListLabels, type TradeHistoryItem } from './trade-history-list-block.js';
|
|
34
|
+
export { TradeHistoryDetailBlock, type TradeHistoryDetailBlockProps, type TradeHistoryDetailLabels, type TradeHistoryDetail, type TradeHistoryAction } from './trade-history-detail-block.js';
|
|
35
|
+
export { TargetBlock, targetLayout, targetFormat, type TargetBlockProps, type TargetBlockLabels, type TargetKind, type TargetUnit, type TargetPrice } from './target-block.js';
|
|
36
|
+
export { ProfileBlock, type ProfileBlockProps, type ProfileRow, type ProfileSection, type ProfileStatus } from './profile-block.js';
|
|
37
|
+
export { PositionBlock, type PositionBlockProps, type PositionBlockDetail, type PositionBlockFigure, type PositionBlockRow, type PositionBlockFlag } from './position-block.js';
|
|
38
|
+
export { RewardBlock, rewardProgress, type RewardBlockProps, type RewardPromo, type RewardEntry } from './reward-block.js';
|
|
39
|
+
export { SoundHapticsBlock, soundLevel, type SoundHapticsBlockProps, type SoundSection, type SoundVolume } from './sound-haptics-block.js';
|
|
40
|
+
export { SignalsBlock, type SignalsBlockProps, type SignalsGroup, type SignalsItem } from './signals-block.js';
|
|
41
|
+
export { NotificationsBlock, type NotificationsBlockProps, type NotificationsItem } from './notifications-block.js';
|
|
42
|
+
export { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker, type FromPickerBlockProps, type ToPickerBlockProps, type FromPickerProps, type ToPickerProps, type PickerListProps } from './pickers.js';
|
|
43
|
+
export { SwapKeypad, SwapCapsule } from './swap-parts.js';
|
|
44
|
+
export { SwapPanelBlock, SwapPanel, swapAction, type SwapPanelBlockProps, type SwapPanelProps, type SwapToken, type SwapArtwork, type SwapChain, type SwapAction, type SwapDenomination, type SwapWallet, type SwapFee, type SwapFigure, type SwapReceive, type SwapDestination, type SwapDetail, type SwapView } from './swap-panel-block.js';
|
|
@@ -2,20 +2,19 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { Platform } from 'react-native';
|
|
4
4
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
|
-
import {
|
|
5
|
+
import { useHIG } from './provider.js';
|
|
6
6
|
import { Button, Link } from './button.js';
|
|
7
7
|
import { Surface, Stack, Heading, Text } from './surface.js';
|
|
8
|
-
import { Field,
|
|
8
|
+
import { Field, Input } from './field.js';
|
|
9
9
|
import { Dialog } from './overlay.js';
|
|
10
|
-
import { Row, Usd, Percent
|
|
10
|
+
import { Row, Usd, Percent } from './data.js';
|
|
11
11
|
import { Toast, useTransientNotice } from './status.js';
|
|
12
12
|
export function MarketRow({ symbol, name, price, change, onSelect }) { return _jsxs(Row, { children: [_jsxs(Button, { intent: 'ghost', onPress: onSelect, children: [name, " (", symbol, ")"] }), _jsx(Usd, { value: price }), _jsx(Percent, { value: change })] }); }
|
|
13
|
-
export function BalanceCard({ label, balance, stale }) { const colors = useColors(); return _jsxs(Surface, { style: { gap: 8 }, children: [_jsx(Text, { style: { color: colors.muted, fontSize: 14, lineHeight: 21 }, children: label }), _jsx(Usd, { value: balance, stale: stale, style: { fontSize: 24, lineHeight: 30, fontWeight: '600' } })] }); }
|
|
14
13
|
/** The call to action that closes a form sits a double step, 16dp, below it (the Stack gap is 12). */
|
|
15
14
|
const formAction = { marginTop: 4 };
|
|
16
15
|
/** In a dialog the confirm action is 16dp below the content and 8dp above the dialog's own closing button, which adds 4dp itself. */
|
|
17
16
|
const dialogAction = { marginTop: 4, marginBottom: -8 };
|
|
18
|
-
export function TradeEntry({ asset, amount, onAmountChange, onConfirm, busy, error, available }) { const { messages } = useHIG(); const [review, setReview] = useState(false); return _jsx(Surface, { children: _jsxs(Stack, { children: [_jsx(Heading, { children: (messages.reviewAssetOrder ?? en.reviewAssetOrder)(asset) }), _jsx(Field, { label: (messages.amountInAsset ?? en.amountInAsset)(asset), description: (messages.availableAmount ?? en.availableAmount)(available), error: error, children: _jsx(
|
|
17
|
+
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, { keyboardType: 'decimal-pad', value: amount, onChangeText: onAmountChange, editable: !busy }) }), _jsx(Button, { fullWidth: true, style: formAction, disabled: !amount || !!error, busy: busy, onPress: () => setReview(true), children: messages.reviewOrder ?? en.reviewOrder }), _jsxs(Dialog, { open: review, onOpenChange: setReview, title: messages.confirmOrder ?? en.confirmOrder, description: (messages.confirmOrderDescription ?? en.confirmOrderDescription)(amount, asset), children: [_jsx(Button, { busy: busy, disabled: !!error, style: dialogAction, onPress: onConfirm, children: messages.confirmOrder ?? en.confirmOrder }), error && _jsx(Text, { accessibilityLiveRegion: 'polite', children: error })] })] }) }); }
|
|
19
18
|
/** Code and commands stay monospace and left-to-right inside RTL roots. */
|
|
20
19
|
function useCodeStyle() { const env = useHIG(); return { fontFamily: env.monoFontFamily ?? Platform.select({ ios: 'Menlo', default: 'monospace' }), writingDirection: 'ltr', textAlign: 'left' }; }
|
|
21
20
|
/** A copy outcome shows as a transient toast capsule (about 4s, dismissible) and is announced the way Toast announces any notice. */
|
|
@@ -25,9 +24,20 @@ export function InstallCommand({ command, onCopy }) {
|
|
|
25
24
|
const code = useCodeStyle();
|
|
26
25
|
return _jsxs(Surface, { style: { gap: 12 }, children: [_jsx(Text, { selectable: true, style: code, children: command }), _jsx(Button, { intent: 'secondary', onPress: () => { Promise.resolve().then(onCopy).then(() => show(messages.copied ?? en.copied, 'success')).catch(() => show(messages.copyFailed ?? en.copyFailed, 'error')); }, children: messages.copyInstallCommand ?? en.copyInstallCommand }), notice && _jsx(Toast, { notices: [notice], onDismiss: dismiss })] });
|
|
27
26
|
}
|
|
28
|
-
export function CodeWindow({ language, children }) { const code = useCodeStyle(); return _jsxs(Surface, { children: [_jsx(Text, { children: language }), _jsx(Text, { selectable: true, style: code, children: children })] }); }
|
|
29
27
|
export function MarketingHero({ title, description, href, cta }) { return _jsxs(Stack, { children: [_jsx(Heading, { children: title }), _jsx(Text, { children: description }), _jsx(Link, { href: href, children: cta })] }); }
|
|
30
|
-
export
|
|
31
|
-
export {
|
|
28
|
+
export { AccountBlock, accountRows, assetValue, AssetBalanceRow } from './account-block.js';
|
|
29
|
+
export { LanguageBlock, filterLanguages } from './language-block.js';
|
|
30
|
+
export { TokenActionBlock, tokenActionLabel } from './token-action-block.js';
|
|
31
|
+
export { ManagePositionBlock, positionCorridor } from './manage-position-block.js';
|
|
32
|
+
export { TradeHistoryListBlock, tradeHistorySide } from './trade-history-list-block.js';
|
|
33
|
+
export { TradeHistoryDetailBlock } from './trade-history-detail-block.js';
|
|
34
|
+
export { TargetBlock, targetLayout, targetFormat } from './target-block.js';
|
|
35
|
+
export { ProfileBlock } from './profile-block.js';
|
|
36
|
+
export { PositionBlock } from './position-block.js';
|
|
37
|
+
export { RewardBlock, rewardProgress } from './reward-block.js';
|
|
38
|
+
export { SoundHapticsBlock, soundLevel } from './sound-haptics-block.js';
|
|
39
|
+
export { SignalsBlock } from './signals-block.js';
|
|
40
|
+
export { NotificationsBlock } from './notifications-block.js';
|
|
41
|
+
export { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker } from './pickers.js';
|
|
32
42
|
export { SwapKeypad, SwapCapsule } from './swap-parts.js';
|
|
33
|
-
export { SwapPanel, swapAction } from './swap-panel.js';
|
|
43
|
+
export { SwapPanelBlock, SwapPanel, swapAction } from './swap-panel-block.js';
|
package/native/dist/field.d.ts
CHANGED
|
@@ -12,5 +12,4 @@ export declare const Label: typeof Text;
|
|
|
12
12
|
/** No resting stroke: the fill separates the field (one step lighter inside a Surface, Dialog or sheet). The ring appears only for focus and for an invalid value. */
|
|
13
13
|
export declare const Input: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<React.ComponentRef<typeof TextInput>>>;
|
|
14
14
|
export declare const TextArea: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<React.ComponentRef<typeof TextInput>>>;
|
|
15
|
-
export declare const AmountInput: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<React.ComponentRef<typeof TextInput>>>;
|
|
16
15
|
export declare const SearchInput: React.ForwardRefExoticComponent<TextInputProps & React.RefAttributes<React.ComponentRef<typeof TextInput>>>;
|
package/native/dist/field.js
CHANGED
|
@@ -11,7 +11,6 @@ export const Label = Text;
|
|
|
11
11
|
/** No resting stroke: the fill separates the field (one step lighter inside a Surface, Dialog or sheet). The ring appears only for focus and for an invalid value. */
|
|
12
12
|
export const Input = forwardRef(function Input({ style, onFocus, onBlur, ...props }, ref) { const field = useContext(Context); const colors = useColors(); const fills = useFills(); const env = useHIG(); const [focused, setFocused] = useState(false); return _jsx(TextInput, { ...props, ref: ref, accessibilityLabel: props.accessibilityLabel ?? field.label, accessibilityHint: props.accessibilityHint ?? field.hint, accessibilityState: { ...props.accessibilityState, disabled: !!field.disabled || !!props.accessibilityState?.disabled }, editable: field.disabled ? false : props.editable, onChangeText: field.disabled ? undefined : props.onChangeText, onChange: field.disabled ? undefined : props.onChange, onFocus: event => { setFocused(true); onFocus?.(event); }, onBlur: event => { setFocused(false); onBlur?.(event); }, placeholderTextColor: props.placeholderTextColor ?? colors.muted, style: [{ color: colors.text, backgroundColor: fills.well, minHeight: 48, borderWidth: 1.5, borderColor: field.invalid ? colors.negative : focused ? colors.faint : 'transparent', borderRadius: props.multiline ? 14 : 9999, paddingVertical: 12, paddingHorizontal: 20, fontSize: 16, fontFamily: env.fontFamilies?.[400] ?? env.fontFamily, opacity: field.disabled ? 0.5 : 1 }, style] }); });
|
|
13
13
|
export const TextArea = forwardRef(function TextArea(props, ref) { return _jsx(Input, { ...props, ref: ref, multiline: true, textAlignVertical: 'top' }); });
|
|
14
|
-
export const AmountInput = forwardRef(function AmountInput(props, ref) { return _jsx(Input, { ...props, ref: ref, keyboardType: props.keyboardType ?? 'decimal-pad' }); });
|
|
15
14
|
/** The magnifying glass sits inset on the leading edge and the text starts past it. */
|
|
16
15
|
/** A search box is as tall as a button, 44dp, not a 48dp form field. */
|
|
17
16
|
const searchSize = { minHeight: 44, paddingVertical: 10 };
|