@bloxwap/hig 0.5.2 → 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/README.md +1 -1
- 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 +37 -4
- package/contracts/dist/messages.js +13 -2
- package/feedback/README.md +1 -1
- package/native/README.md +1 -1
- package/native/dist/account-block.d.ts +92 -0
- package/native/dist/account-block.js +61 -0
- 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 +36 -0
- package/native/dist/asset-balance-row.js +26 -0
- package/native/dist/bar-mark.d.ts +57 -0
- package/native/dist/bar-mark.js +48 -0
- package/native/dist/bar-pnl.d.ts +50 -0
- package/native/dist/bar-pnl.js +60 -0
- package/native/dist/blocks.d.ts +38 -0
- package/native/dist/blocks.js +42 -0
- 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 -5
- package/native/dist/field.js +33 -8
- package/native/dist/figure.d.ts +23 -0
- package/native/dist/figure.js +10 -0
- package/native/dist/icons.d.ts +8 -0
- package/native/dist/icons.js +4 -0
- package/native/dist/language-block.d.ts +35 -0
- package/native/dist/language-block.js +30 -0
- package/native/dist/list-group.d.ts +60 -0
- package/native/dist/list-group.js +85 -0
- package/native/dist/manage-position-block.d.ts +95 -0
- package/native/dist/manage-position-block.js +82 -0
- package/native/dist/market-row.d.ts +46 -0
- package/native/dist/market-row.js +30 -0
- package/native/dist/notifications-block.d.ts +53 -0
- package/native/dist/notifications-block.js +22 -0
- package/native/dist/pickers.d.ts +35 -5
- package/native/dist/pickers.js +21 -9
- package/native/dist/position-block.d.ts +107 -0
- package/native/dist/position-block.js +55 -0
- package/native/dist/profile-block.d.ts +66 -0
- package/native/dist/profile-block.js +48 -0
- 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 -46
- package/native/dist/recipes.js +6 -33
- package/native/dist/reward-block.d.ts +122 -0
- package/native/dist/reward-block.js +53 -0
- 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 -0
- package/native/dist/setting-header.js +2 -0
- package/native/dist/setting-switch.d.ts +31 -0
- package/native/dist/setting-switch.js +20 -0
- package/native/dist/signals-block.d.ts +61 -0
- package/native/dist/signals-block.js +26 -0
- package/native/dist/sound-haptics-block.d.ts +66 -0
- package/native/dist/sound-haptics-block.js +32 -0
- 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.d.ts → swap-panel-block.d.ts} +8 -3
- package/native/dist/{swap-panel.js → swap-panel-block.js} +13 -8
- 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-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 +9 -7
- 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 +110 -0
- package/native/dist/target-block.js +74 -0
- package/native/dist/token-action-block.d.ts +47 -0
- package/native/dist/token-action-block.js +28 -0
- package/native/dist/trade-history-detail-block.d.ts +84 -0
- package/native/dist/trade-history-detail-block.js +46 -0
- package/native/dist/trade-history-list-block.d.ts +110 -0
- package/native/dist/trade-history-list-block.js +64 -0
- 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 +266 -41
- 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 +35 -0
- package/react/dist/asset-balance-row.js +18 -0
- package/react/dist/bar-mark.d.ts +38 -0
- package/react/dist/bar-mark.js +23 -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 +92 -0
- package/react/dist/blocks/account-block.js +62 -0
- package/react/dist/blocks/language-block.d.ts +36 -0
- package/react/dist/blocks/language-block.js +52 -0
- package/react/dist/blocks/manage-position-block.d.ts +93 -0
- package/react/dist/blocks/manage-position-block.js +47 -0
- package/react/dist/blocks/market-row.d.ts +36 -0
- package/react/dist/blocks/market-row.js +16 -0
- package/react/dist/blocks/notifications-block.d.ts +46 -0
- package/react/dist/blocks/notifications-block.js +17 -0
- package/react/dist/{recipes → blocks}/pickers.d.ts +32 -4
- package/react/dist/{recipes → blocks}/pickers.js +35 -11
- package/react/dist/blocks/position-block.d.ts +72 -0
- package/react/dist/blocks/position-block.js +25 -0
- package/react/dist/blocks/profile-block.d.ts +71 -0
- package/react/dist/blocks/profile-block.js +41 -0
- package/react/dist/blocks/reward-block.d.ts +120 -0
- package/react/dist/blocks/reward-block.js +34 -0
- package/react/dist/blocks/screen-header.d.ts +33 -0
- package/react/dist/blocks/screen-header.js +20 -0
- package/react/dist/blocks/setting-switch.d.ts +23 -0
- package/react/dist/blocks/setting-switch.js +12 -0
- package/react/dist/blocks/signals-block.d.ts +54 -0
- package/react/dist/blocks/signals-block.js +15 -0
- package/react/dist/blocks/sound-haptics-block.d.ts +59 -0
- package/react/dist/blocks/sound-haptics-block.js +22 -0
- 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 +8 -0
- package/react/dist/{recipes → blocks}/swap/picker.d.ts +1 -1
- package/react/dist/{recipes → blocks}/swap/picker.js +4 -4
- package/react/dist/{recipes → blocks}/swap/settings.js +2 -2
- package/react/dist/{recipes → blocks}/swap/shared.d.ts +8 -1
- package/react/dist/{recipes → blocks}/swap/shared.js +7 -4
- package/react/dist/{recipes/swap-panel.d.ts → blocks/swap-panel-block.d.ts} +8 -2
- package/react/dist/{recipes/swap-panel.js → blocks/swap-panel-block.js} +9 -7
- 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 +103 -0
- package/react/dist/blocks/target-block.js +73 -0
- package/react/dist/blocks/token-action-block.d.ts +46 -0
- package/react/dist/blocks/token-action-block.js +21 -0
- package/react/dist/{recipes → blocks}/trade-entry.js +2 -2
- package/react/dist/blocks/trade-history-detail-block.d.ts +78 -0
- package/react/dist/blocks/trade-history-detail-block.js +17 -0
- package/react/dist/blocks/trade-history-list-block.d.ts +67 -0
- package/react/dist/blocks/trade-history-list-block.js +28 -0
- package/react/dist/blocks.d.ts +20 -0
- package/react/dist/blocks.js +21 -0
- package/react/dist/button.js +6 -4
- package/react/dist/data.js +3 -3
- package/react/dist/field.d.ts +14 -6
- package/react/dist/field.js +19 -8
- package/react/dist/figure.d.ts +23 -0
- package/react/dist/figure.js +12 -0
- package/react/dist/list-group.d.ts +59 -0
- package/react/dist/list-group.js +52 -0
- 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 +425 -5
- 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
- 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/market-row.d.ts +0 -25
- package/react/dist/recipes/market-row.js +0 -8
- package/react/dist/recipes/swap/amount-card.js +0 -7
- 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}/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/settings.d.ts +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.7.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
|
@@ -19,6 +19,22 @@ export type HostLocale = string | {
|
|
|
19
19
|
* only in apps that lay out right to left: it reports the locale's direction, not whether the host allows RTL (#86).
|
|
20
20
|
*/
|
|
21
21
|
export declare function localeDirection(locale: HostLocale | null | undefined): Direction | undefined;
|
|
22
|
+
/** How money reads across a provider: the currency sign and digit grouping a host's own figures use, such as `narrowSymbol` so French reads `12,50 $` rather than `12,50 $US`. */
|
|
23
|
+
export interface NumberFormatPresentation {
|
|
24
|
+
/** How the currency is named. Intl's default is `symbol`. */
|
|
25
|
+
currencyDisplay?: 'symbol' | 'narrowSymbol' | 'code' | 'name';
|
|
26
|
+
/** Digit grouping. `'always'` groups four-digit amounts in locales that otherwise leave them ungrouped, such as Spanish. */
|
|
27
|
+
useGrouping?: boolean | 'always' | 'auto' | 'min2';
|
|
28
|
+
/** The locale numbers are formatted in, when it differs from the provider's interface `locale`: `'en-US'` keeps Korean or Chinese figures in US separators. It changes every number HIG formats (separators, digits and currency placement), not only money. Omitted, numbers follow the provider's `locale`. */
|
|
29
|
+
locale?: string;
|
|
30
|
+
}
|
|
31
|
+
/** The locale HIG formats numbers in: the presentation's `locale` when it names one, otherwise the interface locale. */
|
|
32
|
+
export declare function numberLocale(locale: string, presentation?: NumberFormatPresentation): string;
|
|
33
|
+
/**
|
|
34
|
+
* Merges a provider's money presentation under the options of one currency format. Only `style: 'currency'` options change, and any
|
|
35
|
+
* field the options set themselves wins. Without a presentation, or for any other style, the same options object is returned.
|
|
36
|
+
*/
|
|
37
|
+
export declare function presentNumberFormat<T extends Intl.NumberFormatOptions | undefined>(options: T, presentation?: NumberFormatPresentation): T;
|
|
22
38
|
/** Display only. Keep raw decimal strings in transaction logic. */
|
|
23
39
|
export declare function formatNumber(value: number | null | undefined, locale?: string, options?: Intl.NumberFormatOptions): string;
|
|
24
40
|
/** Leverage multiplier display (`10×`). Never percent-styled; the `×` suffix is untranslated. Unknown → `—`. */
|
package/contracts/dist/index.js
CHANGED
|
@@ -23,6 +23,28 @@ export function localeDirection(locale) {
|
|
|
23
23
|
const script = (singleton < 0 ? rest : rest.slice(0, singleton)).find(subtag => /^[a-z]{4}$/.test(subtag));
|
|
24
24
|
return (script ? rtlScripts.has(script) : rtlLanguages.has(language)) ? 'rtl' : 'ltr';
|
|
25
25
|
}
|
|
26
|
+
/** The locale HIG formats numbers in: the presentation's `locale` when it names one, otherwise the interface locale. */
|
|
27
|
+
export function numberLocale(locale, presentation) {
|
|
28
|
+
const own = presentation?.locale;
|
|
29
|
+
return typeof own === 'string' && own.trim() !== '' ? own : locale;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Merges a provider's money presentation under the options of one currency format. Only `style: 'currency'` options change, and any
|
|
33
|
+
* field the options set themselves wins. Without a presentation, or for any other style, the same options object is returned.
|
|
34
|
+
*/
|
|
35
|
+
export function presentNumberFormat(options, presentation) {
|
|
36
|
+
if (!presentation || options?.style !== 'currency')
|
|
37
|
+
return options;
|
|
38
|
+
const merged = {};
|
|
39
|
+
if (presentation.currencyDisplay !== undefined)
|
|
40
|
+
merged.currencyDisplay = presentation.currencyDisplay;
|
|
41
|
+
if (presentation.useGrouping !== undefined)
|
|
42
|
+
merged.useGrouping = presentation.useGrouping;
|
|
43
|
+
for (const [key, value] of Object.entries(options))
|
|
44
|
+
if (value !== undefined)
|
|
45
|
+
merged[key] = value;
|
|
46
|
+
return merged;
|
|
47
|
+
}
|
|
26
48
|
/** Display only. Keep raw decimal strings in transaction logic. */
|
|
27
49
|
export function formatNumber(value, locale = 'en-US', options = {}) {
|
|
28
50
|
return value == null || !Number.isFinite(value) ? '—' : new Intl.NumberFormat(locale, options).format(value);
|
|
@@ -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,30 @@ 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
|
+
/** ProfileBlock: accessible name of the avatar button when the host gives neither `avatarLabel` nor `name`. */
|
|
210
|
+
changeProfilePicture: string;
|
|
211
|
+
/** TokenActionBlock: built-in label of the `receive` action. */
|
|
212
|
+
receive: string;
|
|
213
|
+
/** TokenActionBlock: built-in label of the `stake` action. */
|
|
214
|
+
stake: string;
|
|
215
|
+
/** TokenActionBlock: built-in label of the `unstake` action. */
|
|
216
|
+
unstake: string;
|
|
217
|
+
/** SearchInput: accessible name of the clear button when the host gives no `clearLabel`. */
|
|
218
|
+
clearSearch: string;
|
|
197
219
|
}
|
|
198
220
|
export declare const close = "Close";
|
|
199
221
|
export declare const cancel = "Cancel";
|
|
@@ -236,7 +258,6 @@ export declare const reviewOrder = "Review order";
|
|
|
236
258
|
export declare const confirmOrder = "Confirm order";
|
|
237
259
|
export declare const confirmOrderDescription: (amount: string, asset: string) => string;
|
|
238
260
|
export declare const orderUnavailable = "Order unavailable";
|
|
239
|
-
export declare const noActivity = "No activity yet";
|
|
240
261
|
export declare const statusOnline = "online";
|
|
241
262
|
export declare const statusOffline = "offline";
|
|
242
263
|
export declare const statusStale = "stale";
|
|
@@ -288,6 +309,18 @@ export declare const qrCode = "QR code";
|
|
|
288
309
|
export declare const swapControlKey = "Ctrl";
|
|
289
310
|
export declare const swapKeypad = "Keypad";
|
|
290
311
|
export declare const swapDelete = "Delete";
|
|
312
|
+
export declare const account = "Account";
|
|
313
|
+
export declare const deposit = "Deposit";
|
|
314
|
+
export declare const accountBalance = "Total balance";
|
|
315
|
+
export declare const showAddress = "Show account address";
|
|
316
|
+
export declare const editName = "Edit name";
|
|
317
|
+
export declare const changeProfilePicture = "Change profile picture";
|
|
318
|
+
export declare const language = "Language";
|
|
319
|
+
export declare const searchLanguages = "Search languages";
|
|
320
|
+
export declare const receive = "Receive";
|
|
321
|
+
export declare const stake = "Stake";
|
|
322
|
+
export declare const unstake = "Unstake";
|
|
323
|
+
export declare const clearSearch = "Clear search";
|
|
291
324
|
/** The complete English catalog. */
|
|
292
325
|
export declare const defaultMessages: Readonly<HIGMessages>;
|
|
293
326
|
/** 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,20 @@ 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 changeProfilePicture = 'Change profile picture';
|
|
100
|
+
export const language = 'Language';
|
|
101
|
+
export const searchLanguages = 'Search languages';
|
|
102
|
+
export const receive = 'Receive';
|
|
103
|
+
export const stake = 'Stake';
|
|
104
|
+
export const unstake = 'Unstake';
|
|
105
|
+
export const clearSearch = 'Clear search';
|
|
95
106
|
/** 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,
|
|
107
|
+
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, changeProfilePicture, language, searchLanguages, receive, stake, unstake, clearSearch };
|
|
97
108
|
/** Every message key, in documentation order. */
|
|
98
109
|
export const messageKeys = /* @__PURE__ */ Object.keys(defaultMessages);
|
|
99
110
|
/**
|
package/feedback/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bloxwap/hig/feedback
|
|
2
2
|
|
|
3
|
-
Version 0.
|
|
3
|
+
Version 0.7.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.7.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,92 @@
|
|
|
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
|
+
/** Set false to draw no units line, for a holding whose units are the same figure as its value. */
|
|
17
|
+
units?: boolean;
|
|
18
|
+
/** Set false to draw this row plain even when the block has `onAssetSelect`. */
|
|
19
|
+
selectable?: boolean;
|
|
20
|
+
/** Format of the units figure; default `{maximumFractionDigits:6}`. */
|
|
21
|
+
unitsOptions?: Intl.NumberFormatOptions;
|
|
22
|
+
/** Host text after the units figure, such as ` PAPER`. */
|
|
23
|
+
unitsSuffix?: string;
|
|
24
|
+
/** Short muted host text under the figures, such as the ledger the holding sits in (Perp, Spot, Staked). */
|
|
25
|
+
tag?: string;
|
|
26
|
+
/** When the value is unknown but the balance is known: `units` (the default) headlines the units; `dash` shows the unknown dash over the units, for a value that is still loading. */
|
|
27
|
+
unknownValue?: 'units' | 'dash';
|
|
28
|
+
}
|
|
29
|
+
/** Row order after the pinned asset: `value` (largest first, the default) or `given` (the order the host passed). */
|
|
30
|
+
export type AccountOrder = 'value' | 'given';
|
|
31
|
+
/** How `accountRows` picks and orders: `order` after the pinned asset, and `pinnedId`, an asset id pinned in place of the symbol match. */
|
|
32
|
+
export interface AccountRowsOptions {
|
|
33
|
+
order?: AccountOrder;
|
|
34
|
+
pinnedId?: string;
|
|
35
|
+
}
|
|
36
|
+
/** A titled group of holdings with its own total, such as one ledger of the account. */
|
|
37
|
+
export interface AccountSection {
|
|
38
|
+
id: string;
|
|
39
|
+
/** Heading over the group. */
|
|
40
|
+
title: string;
|
|
41
|
+
/** The group's total in dollars, on the trailing edge of its heading; defaults to the sum of its asset values. `null` shows it as unknown. */
|
|
42
|
+
total?: number | null;
|
|
43
|
+
assets: readonly AccountAsset[];
|
|
44
|
+
/** Row order in this group; defaults to the block's `order`. */
|
|
45
|
+
order?: AccountOrder;
|
|
46
|
+
/** Id of the asset that leads this group; defaults to the block's `pinnedId`, then the `pinnedSymbol` match. */
|
|
47
|
+
pinnedId?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface AccountBlockProps {
|
|
50
|
+
/** Defaults to the localized "Account". */
|
|
51
|
+
title?: string;
|
|
52
|
+
/** Shows Back on the leading edge of the header. */
|
|
53
|
+
onBack?: () => void;
|
|
54
|
+
/** 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. */
|
|
55
|
+
onShowAddress?: () => void;
|
|
56
|
+
/** A control on the trailing edge of the header, usually an IconButton. Replaces the QR button. */
|
|
57
|
+
headerAction?: React.ReactNode;
|
|
58
|
+
/** Total in dollars; defaults to the sum of the asset values (with `sections`, the sum of the totals of the sections that are drawn, which is unknown when any of those totals is). `null` shows it as unknown. */
|
|
59
|
+
balance?: number | null;
|
|
60
|
+
/** Every holding as one list: the pinned asset, then the rest by value. Ignored when `sections` is set. */
|
|
61
|
+
assets?: readonly AccountAsset[];
|
|
62
|
+
/** Titled groups, each with its own total, drawn in the order given in place of the flat `assets` list. */
|
|
63
|
+
sections?: readonly AccountSection[];
|
|
64
|
+
/** Symbol of the asset pinned first; default 'USDC'. */
|
|
65
|
+
pinnedSymbol?: string;
|
|
66
|
+
/** Id of the asset pinned first, in place of the `pinnedSymbol` match, for a holding whose symbol is not unique. */
|
|
67
|
+
pinnedId?: string;
|
|
68
|
+
/** Order of the rows after the pinned one: `value` (largest first, the default) or `given` (the order passed). */
|
|
69
|
+
order?: AccountOrder;
|
|
70
|
+
/** Shows the deposit action beside the total. */
|
|
71
|
+
onDeposit?: () => void;
|
|
72
|
+
depositLabel?: string;
|
|
73
|
+
/** Makes each row a button that reports its asset, and with `sections` the section it is in. */
|
|
74
|
+
onAssetSelect?: (asset: AccountAsset, section?: AccountSection) => void;
|
|
75
|
+
testID?: string;
|
|
76
|
+
}
|
|
77
|
+
/** An asset's dollar value: its own `value`, else balance × price, else unknown. */
|
|
78
|
+
export declare const assetValue: (asset: AccountAsset) => number | null;
|
|
79
|
+
/** The pinned asset (the one with `options.pinnedId`, else the first with `pinnedSymbol`, else a zero placeholder) and the rest by dollar value, largest first, unknown values last, ties by name, or with `options.order` `given` in the order passed. */
|
|
80
|
+
export declare function accountRows(assets: readonly AccountAsset[], pinnedSymbol?: string, options?: AccountRowsOptions): {
|
|
81
|
+
pinned: AccountAsset;
|
|
82
|
+
rest: AccountAsset[];
|
|
83
|
+
};
|
|
84
|
+
/** A section's total: its own `total`, or the sum of its asset values. */
|
|
85
|
+
export declare const accountSectionTotal: (section: AccountSection) => number | null;
|
|
86
|
+
/** A section's rows in display order: the pinned asset first when the section holds it (no placeholder), then the rest by value as in `accountRows`. */
|
|
87
|
+
export declare function accountSectionRows(assets: readonly AccountAsset[], pinnedSymbol?: string, options?: AccountRowsOptions): {
|
|
88
|
+
pinned: AccountAsset | null;
|
|
89
|
+
rest: AccountAsset[];
|
|
90
|
+
};
|
|
91
|
+
/** The account as one screen: a header, the total with the deposit action, the pinned asset, then every other holding by value. */
|
|
92
|
+
export declare function AccountBlock({ title, onBack, onShowAddress, headerAction, balance, assets, sections, pinnedSymbol, pinnedId, order, onDeposit, depositLabel, onAssetSelect, testID }: AccountBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
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 (the one with `options.pinnedId`, else the first with `pinnedSymbol`, else a zero placeholder) and the rest by dollar value, largest first, unknown values last, ties by name, or with `options.order` `given` in the order passed. */
|
|
15
|
+
export function accountRows(assets, pinnedSymbol = usdc, options = {}) {
|
|
16
|
+
const wanted = pinnedSymbol.toLowerCase();
|
|
17
|
+
const found = (options.pinnedId === undefined ? undefined : assets.find(asset => asset.id === options.pinnedId)) ?? assets.find(asset => asset.symbol.toLowerCase() === wanted);
|
|
18
|
+
const pinned = found ?? { id: pinnedSymbol, name: pinnedSymbol === usdc ? usdCoin : pinnedSymbol, symbol: pinnedSymbol, balance: 0, value: 0 };
|
|
19
|
+
const others = assets.filter(asset => asset !== found);
|
|
20
|
+
const rest = options.order === 'given' ? others : others.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); });
|
|
21
|
+
return { pinned, rest };
|
|
22
|
+
}
|
|
23
|
+
const sum = (assets) => assets.reduce((total, asset) => total + (assetValue(asset) ?? 0), 0);
|
|
24
|
+
/** A section's total: its own `total`, or the sum of its asset values. */
|
|
25
|
+
export const accountSectionTotal = (section) => section.total !== undefined ? section.total : sum(section.assets);
|
|
26
|
+
/** The block total for `sections`: the sum of the section totals, or unknown (`null`) when any of them is unknown. Pass only the sections that are drawn. */
|
|
27
|
+
const accountSectionsTotal = (sections) => { let all = 0; for (const section of sections) {
|
|
28
|
+
const total = accountSectionTotal(section);
|
|
29
|
+
if (total === null)
|
|
30
|
+
return null;
|
|
31
|
+
all += total;
|
|
32
|
+
} return all; };
|
|
33
|
+
/** A section's rows in display order: the pinned asset first when the section holds it (no placeholder), then the rest by value as in `accountRows`. */
|
|
34
|
+
export function accountSectionRows(assets, pinnedSymbol = usdc, options = {}) {
|
|
35
|
+
const { pinned, rest } = accountRows(assets, pinnedSymbol, options);
|
|
36
|
+
return { pinned: assets.includes(pinned) ? pinned : null, rest };
|
|
37
|
+
}
|
|
38
|
+
/** The account as one screen: a header, the total with the deposit action, the pinned asset, then every other holding by value. */
|
|
39
|
+
export function AccountBlock({ title, onBack, onShowAddress, headerAction, balance, assets = [], sections, pinnedSymbol = usdc, pinnedId, order, onDeposit, depositLabel, onAssetSelect, testID }) {
|
|
40
|
+
const colors = useColors(), t = useMessages(), { direction } = useHIG();
|
|
41
|
+
const shown = sections?.filter(section => section.assets.length > 0);
|
|
42
|
+
const total = balance !== undefined ? balance : shown ? accountSectionsTotal(shown) : sum(assets);
|
|
43
|
+
const row = (asset, pin, pinId, section, prefix = 'account-asset') => {
|
|
44
|
+
// A row pinned by symbol is the dollar balance, so its units would repeat its value; a row pinned by id keeps its own units setting.
|
|
45
|
+
const value = assetValue(asset), units = (!pin || asset.id === pinId) && asset.units !== false;
|
|
46
|
+
const select = onAssetSelect && asset.selectable !== false ? (section ? () => onAssetSelect(asset, section) : () => onAssetSelect(asset)) : undefined;
|
|
47
|
+
return _jsx(AssetBalanceRow, { testID: `${prefix}-${asset.id}`, name: asset.name, symbol: asset.symbol, icon: asset.icon, value: value, balance: units ? asset.balance ?? null : undefined, balanceOptions: asset.unitsOptions, unitsSuffix: asset.unitsSuffix, tag: asset.tag, headline: units && value === null && asset.balance != null && asset.unknownValue !== 'dash' ? 'units' : undefined, onSelect: select }, asset.id);
|
|
48
|
+
};
|
|
49
|
+
let list;
|
|
50
|
+
if (shown)
|
|
51
|
+
list = _jsx(View, { testID: 'account-sections', style: { gap: 24, marginTop: 16 }, children: shown.map(section => {
|
|
52
|
+
const pinId = section.pinnedId ?? pinnedId;
|
|
53
|
+
const { pinned, rest } = accountSectionRows(section.assets, pinnedSymbol, { order: section.order ?? order, pinnedId: pinId }), prefix = `account-section-${section.id}`, rowPrefix = `${prefix}-asset`;
|
|
54
|
+
return _jsxs(View, { testID: prefix, style: { gap: 8 }, children: [_jsxs(View, { testID: `${prefix}-header`, style: { flexDirection: 'row', alignItems: 'baseline', justifyContent: 'space-between', gap: 12, paddingHorizontal: 4 }, children: [_jsx(Text, { accessibilityRole: 'header', testID: `${prefix}-title`, style: { flexShrink: 1, color: colors.muted, fontSize: 14, lineHeight: 20, fontWeight: '500' }, children: section.title }), _jsx(AnimatedNumberReadout, { value: accountSectionTotal(section), options: usd, tone: 'muted', testID: `${prefix}-total`, style: { fontSize: 14, lineHeight: 20, fontWeight: '500' } })] }), _jsxs(View, { testID: `${prefix}-assets`, style: { gap: 8 }, children: [pinned ? row(pinned, true, pinId, section, rowPrefix) : null, rest.map(asset => row(asset, false, pinId, section, rowPrefix))] })] }, section.id);
|
|
55
|
+
}) });
|
|
56
|
+
else {
|
|
57
|
+
const { pinned, rest } = accountRows(assets, pinnedSymbol, { order, pinnedId });
|
|
58
|
+
list = _jsxs(View, { testID: 'account-assets', style: { gap: 8, marginTop: 16 }, children: [row(pinned, true, pinnedId), rest.map(asset => row(asset, false, pinnedId))] });
|
|
59
|
+
}
|
|
60
|
+
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] }), list] });
|
|
61
|
+
}
|
|
@@ -21,4 +21,10 @@ export interface NumberReelModel {
|
|
|
21
21
|
export declare function formatNumberReadout(value: number | null | undefined, locale: string, options?: Intl.NumberFormatOptions, formattedValue?: string, prefix?: string, suffix?: string): NumberReading;
|
|
22
22
|
export declare function numberTrendDirection(trend: NumberTrend | undefined, previousValue: number | null | undefined, value: number | null | undefined): -1 | 0 | 1;
|
|
23
23
|
export declare function safeNumberLayout(text: string, direction: string): boolean;
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Reels for host-formatted text: every digit of `text` (ASCII, or the locale's own digits) becomes a reel keyed by its place
|
|
26
|
+
* counted from the end, and everything else stays as written. Used for a figure's `formattedValue` when the host formats
|
|
27
|
+
* numbers itself, for example because the runtime's Intl does not match its number table.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createFormattedReelModel(text: string, locale: string, direction: string): NumberReelModel | null;
|
|
30
|
+
export declare function createNumberReelModel(value: number | null | undefined, locale: string, options: Intl.NumberFormatOptions | undefined, formattedValue: string | undefined, direction: string, animateFormatted?: boolean): NumberReelModel | null;
|
|
@@ -44,7 +44,56 @@ export function safeNumberLayout(text, direction) {
|
|
|
44
44
|
return false;
|
|
45
45
|
return true;
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
const asciiDigits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|
48
|
+
/** The ten digit glyphs of a locale's numbering system, or `null` when Intl cannot name them one character each. */
|
|
49
|
+
function localeDigits(locale) {
|
|
50
|
+
try {
|
|
51
|
+
const numberingSystem = new Intl.NumberFormat(locale).resolvedOptions().numberingSystem;
|
|
52
|
+
const digitFormatter = new Intl.NumberFormat(locale, { numberingSystem, useGrouping: false, minimumFractionDigits: 0, maximumFractionDigits: 0 });
|
|
53
|
+
const digits = Array.from({ length: 10 }, (_, digit) => { const formatted = digitFormatter.format(digit); return Array.from(formatted).length === 1 ? formatted : ''; });
|
|
54
|
+
return digits.every(Boolean) && new Set(digits).size === 10 ? digits : null;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Reels for host-formatted text: every digit of `text` (ASCII, or the locale's own digits) becomes a reel keyed by its place
|
|
62
|
+
* counted from the end, and everything else stays as written. Used for a figure's `formattedValue` when the host formats
|
|
63
|
+
* numbers itself, for example because the runtime's Intl does not match its number table.
|
|
64
|
+
*/
|
|
65
|
+
export function createFormattedReelModel(text, locale, direction) {
|
|
66
|
+
if (!text || !safeNumberLayout(text, direction))
|
|
67
|
+
return null;
|
|
68
|
+
const characters = Array.from(text), ascii = characters.some(character => asciiDigits.includes(character));
|
|
69
|
+
const digits = ascii ? asciiDigits : localeDigits(locale);
|
|
70
|
+
if (!digits)
|
|
71
|
+
return null;
|
|
72
|
+
const count = characters.filter(character => digits.includes(character)).length;
|
|
73
|
+
if (!count)
|
|
74
|
+
return null;
|
|
75
|
+
const tokens = [];
|
|
76
|
+
let run = '', seen = 0;
|
|
77
|
+
const flush = () => { if (run) {
|
|
78
|
+
tokens.push({ key: `static:${tokens.length}`, kind: 'static', type: 'literal', value: run, partIndex: tokens.length });
|
|
79
|
+
run = '';
|
|
80
|
+
} };
|
|
81
|
+
for (const character of characters) {
|
|
82
|
+
const digit = digits.indexOf(character);
|
|
83
|
+
if (digit < 0) {
|
|
84
|
+
run += character;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
flush();
|
|
88
|
+
const place = count - ++seen;
|
|
89
|
+
tokens.push({ key: `digit:${place}`, kind: 'digit', type: 'integer', value: character, partIndex: tokens.length, digit, place });
|
|
90
|
+
}
|
|
91
|
+
flush();
|
|
92
|
+
return { canonical: text, digits, tokens };
|
|
93
|
+
}
|
|
94
|
+
export function createNumberReelModel(value, locale, options, formattedValue, direction, animateFormatted = false) {
|
|
95
|
+
if (typeof value === 'number' && Number.isFinite(value) && formattedValue && animateFormatted && typeof Intl !== 'undefined')
|
|
96
|
+
return createFormattedReelModel(formattedValue, locale, direction);
|
|
48
97
|
if (typeof value !== 'number' || !Number.isFinite(value) || formattedValue || direction !== 'ltr' || typeof Intl === 'undefined' || typeof Intl.NumberFormat !== 'function')
|
|
49
98
|
return null;
|
|
50
99
|
try {
|
|
@@ -5,5 +5,7 @@ export type AnimatedNumberTrend = NumberTrend;
|
|
|
5
5
|
export interface AnimatedNumberProps extends NumberProps {
|
|
6
6
|
duration?: number;
|
|
7
7
|
trend?: AnimatedNumberTrend;
|
|
8
|
+
/** With `formattedValue`, moves the host's text place by place: each digit it contains rolls in place, counted from the end, and the rest stays as written. Without it `formattedValue` is drawn static, as before. */
|
|
9
|
+
animateFormatted?: boolean;
|
|
8
10
|
}
|
|
9
|
-
export declare function AnimatedNumberReadout({ value, options, formattedValue, stale, label, tone, style, testID, maxFontSizeMultiplier, trend, prefix, suffix, duration }: AnimatedNumberProps): React.JSX.Element;
|
|
11
|
+
export declare function AnimatedNumberReadout({ value, options: requested, formattedValue, animateFormatted, stale, label, tone, style, testID, maxFontSizeMultiplier, trend, prefix, suffix, duration }: AnimatedNumberProps): React.JSX.Element;
|
|
@@ -4,9 +4,10 @@ import { useEffect, useRef, useState } from 'react';
|
|
|
4
4
|
import { PixelRatio, StyleSheet, View } from 'react-native';
|
|
5
5
|
import Reanimated, { cancelAnimation, Easing, ReduceMotion, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
6
6
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
7
|
+
import { presentNumberFormat } from '@bloxwap/hig/contracts';
|
|
7
8
|
import { tokens } from '@bloxwap/hig/tokens';
|
|
8
9
|
import { createNumberReelModel, formatNumberReadout, numberTrendDirection, safeNumberLayout } from './animated-number-model.js';
|
|
9
|
-
import { useColors, useHIG } from './provider.js';
|
|
10
|
+
import { useColors, useHIG, useNumberLocale } from './provider.js';
|
|
10
11
|
import { detectScript, Text } from './surface.js';
|
|
11
12
|
const numberTypographyKeys = new Set(['fontFamily', 'fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'textAlign']);
|
|
12
13
|
// Android Fabric reads colour 0 as "unset", so 'transparent' (0x00000000) drew the hidden reading in the default
|
|
@@ -68,16 +69,18 @@ function recordGlyph(measurements, key, index, event, setMetrics) {
|
|
|
68
69
|
return;
|
|
69
70
|
setMetrics(current => current?.key === key && current.width === measuredWidth && current.height === measuredHeight ? current : { key, width: measuredWidth, height: measuredHeight });
|
|
70
71
|
}
|
|
71
|
-
export function AnimatedNumberReadout({ value, options, formattedValue, stale, label, tone = 'text', style, testID, maxFontSizeMultiplier, trend, prefix, suffix, duration = 180 }) {
|
|
72
|
-
const
|
|
72
|
+
export function AnimatedNumberReadout({ value, options: requested, formattedValue, animateFormatted, stale, label, tone = 'text', style, testID, maxFontSizeMultiplier, trend, prefix, suffix, duration = 180 }) {
|
|
73
|
+
const locale = useNumberLocale();
|
|
74
|
+
const { messages, direction, reducedMotion, fontFamily, fontFamilies, fontFamiliesByScript, letterSpacingByScript, maxFontSizeMultiplier: providerMaxFontSizeMultiplier, numberFormat } = useHIG(), colors = useColors();
|
|
75
|
+
const options = presentNumberFormat(requested, numberFormat);
|
|
73
76
|
const reading = formatNumberReadout(value, locale, options, formattedValue, prefix, suffix), staleSuffix = stale ? ` ${messages.stale ?? en.stale}` : '';
|
|
74
77
|
const previousValue = useRef(value), directionTrend = numberTrendDirection(trend, previousValue.current, value);
|
|
75
78
|
useEffect(() => { previousValue.current = value; }, [value]);
|
|
76
79
|
const typography = Object.fromEntries(Object.entries(StyleSheet.flatten(style) ?? {}).filter(([key]) => numberTypographyKeys.has(key)));
|
|
77
|
-
const color = colors[tone === 'positive' || tone === 'negative' || tone === 'muted' || tone === 'up' || tone === 'down' ? tone : 'text'];
|
|
80
|
+
const color = colors[tone === 'positive' || tone === 'negative' || tone === 'warning' || tone === 'muted' || tone === 'faint' || tone === 'up' || tone === 'down' ? tone : 'text'];
|
|
78
81
|
const textStyle = [typography, { color, fontVariant: ['tabular-nums'] }];
|
|
79
82
|
const script = detectScript(`${reading.text}${staleSuffix}`, locale);
|
|
80
|
-
const model = createNumberReelModel(value, locale, options, formattedValue, direction);
|
|
83
|
+
const model = createNumberReelModel(value, locale, options, formattedValue, direction, animateFormatted);
|
|
81
84
|
const safeModel = model && safeNumberLayout(`${prefix ?? ''}${suffix ?? ''}${staleSuffix}`, direction) ? model : null;
|
|
82
85
|
let fontScale = 0;
|
|
83
86
|
try {
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
/** Host text after the units figure, such as ` HYPE`. Drawn and read only when the units are known. */
|
|
16
|
+
unitsSuffix?: string;
|
|
17
|
+
/** `units` puts the units on the headline line in place of the value and draws no second line, for a holding with no dollar value. Default `value`. */
|
|
18
|
+
headline?: 'value' | 'units';
|
|
19
|
+
/** `false` draws no figures at all, for a row that is just an item to pick, such as a method or a chain. Default `true`. */
|
|
20
|
+
amounts?: boolean;
|
|
21
|
+
/** Short muted host text under the figures, such as the ledger a holding sits in. Read after them. */
|
|
22
|
+
tag?: string;
|
|
23
|
+
/** Host content on the trailing edge, after the figures. Inside a pressable row it must not be interactive. The row reads it as one label, last: its text, or `trailingLabel`. */
|
|
24
|
+
trailing?: React.ReactNode;
|
|
25
|
+
/** What the row reads for `trailing`, in place of its text, for an icon or a figure whose text is not what should be heard. */
|
|
26
|
+
trailingLabel?: string;
|
|
27
|
+
/** Marks the row in use: a check on the trailing edge and `accessibilityState.selected`. */
|
|
28
|
+
selected?: boolean;
|
|
29
|
+
/** Dims the row, ignores presses and reads as unavailable. */
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
/** Makes the row a button. */
|
|
32
|
+
onSelect?: () => void;
|
|
33
|
+
testID?: string;
|
|
34
|
+
}
|
|
35
|
+
/** 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. */
|
|
36
|
+
export declare function AssetBalanceRow({ name, symbol, icon, value, balance, balanceOptions, unitsSuffix, headline, amounts, tag, trailing, trailingLabel, selected, disabled, onSelect, testID }: AssetBalanceRowProps): React.JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
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, useNumberLocale, usePresentNumber } 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
|
+
import { plainText } from './text-content.js';
|
|
8
|
+
const usd = { style: 'currency', currency: 'USD' };
|
|
9
|
+
const units = { maximumFractionDigits: 6 };
|
|
10
|
+
const avatar = 40;
|
|
11
|
+
const hidden = { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' };
|
|
12
|
+
/** 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. */
|
|
13
|
+
export function AssetBalanceRow({ name, symbol, icon, value, balance, balanceOptions = units, unitsSuffix, headline = 'value', amounts = true, tag, trailing, trailingLabel, selected, disabled, onSelect, testID }) {
|
|
14
|
+
const colors = useColors(), fills = useFills(), locale = useNumberLocale(), present = usePresentNumber();
|
|
15
|
+
const unitsFirst = headline === 'units', hasUnits = amounts && !unitsFirst && balance !== undefined;
|
|
16
|
+
const unitsText = () => formatNumberReadout(balance, locale, balanceOptions, undefined, undefined, unitsSuffix).text;
|
|
17
|
+
const headlineText = amounts ? unitsFirst ? unitsText() : formatNumberReadout(value, locale, present(usd)).text : null;
|
|
18
|
+
const label = [name, symbol, headlineText, hasUnits ? unitsText() : null, tag || null, trailingLabel ?? (trailing != null && trailing !== false ? plainText(trailing) : null)].filter(Boolean).join(', ');
|
|
19
|
+
const state = selected || disabled ? { ...(selected ? { selected: true } : {}), ...(disabled ? { disabled: true } : {}) } : undefined;
|
|
20
|
+
const strong = disabled ? colors.muted : colors.text;
|
|
21
|
+
const shape = { width: avatar, height: avatar, borderRadius: avatar / 2, backgroundColor: fills.raised, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' };
|
|
22
|
+
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) }) });
|
|
23
|
+
const row = (pressed) => ({ flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 56, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 28, backgroundColor: pressed && !disabled ? fills.raised : fills.well });
|
|
24
|
+
const content = _jsxs(_Fragment, { children: [_jsx(View, { ...hidden, style: disabled ? { opacity: 0.5 } : undefined, 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: strong }, children: name }), _jsx(Text, { numberOfLines: 1, style: { fontSize: 14, lineHeight: 20, color: colors.muted }, children: symbol })] }), amounts || tag ? _jsxs(View, { ...hidden, style: { alignItems: 'flex-end', justifyContent: 'center' }, children: [amounts ? unitsFirst ? _jsx(AnimatedNumberReadout, { value: balance, options: balanceOptions, suffix: unitsSuffix, tone: disabled ? 'muted' : undefined, testID: testID ? `${testID}-balance` : undefined, style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) : _jsx(AnimatedNumberReadout, { value: value, options: usd, tone: disabled ? 'muted' : undefined, testID: testID ? `${testID}-value` : undefined, style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) : null, hasUnits ? _jsx(AnimatedNumberReadout, { value: balance, options: balanceOptions, suffix: unitsSuffix, tone: 'muted', testID: testID ? `${testID}-balance` : undefined, style: { fontSize: 14, lineHeight: 20 } }) : null, tag ? _jsx(Text, { testID: testID ? `${testID}-tag` : undefined, numberOfLines: 1, style: { fontSize: 12, lineHeight: 18, color: colors.muted }, children: tag }) : null] }) : null, trailing != null && trailing !== false ? _jsx(View, { ...hidden, testID: testID ? `${testID}-trailing` : undefined, style: { flexDirection: 'row', alignItems: 'center', gap: 8 }, children: trailing }) : null, selected ? _jsx(View, { ...hidden, testID: testID ? `${testID}-check` : undefined, style: { width: 20, height: 20, alignItems: 'center', justifyContent: 'center' }, children: _jsx(View, { style: { width: 6, height: 12, borderRightWidth: 2, borderBottomWidth: 2, borderColor: strong, transform: [{ translateY: -1 }, { rotate: '45deg' }] } }) }) : null] });
|
|
25
|
+
return onSelect ? _jsx(Pressable, { testID: testID, accessibilityRole: 'button', accessibilityLabel: label, accessibilityState: state, disabled: disabled, onPress: onSelect, style: ({ pressed }) => row(pressed), children: content }) : _jsx(View, { testID: testID, accessible: true, accessibilityLabel: label, accessibilityState: state, style: row(false), children: content });
|
|
26
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type Figure } from './figure.js';
|
|
3
|
+
/** Colour roles a segment can take. They follow the provider's colour space and market colours as those roles do. */
|
|
4
|
+
export type BarMarkTone = 'positive' | 'info' | 'warning' | 'negative' | 'muted' | 'faint';
|
|
5
|
+
export interface BarMarkElement {
|
|
6
|
+
/** Stable key and testID suffix; the index is used when omitted. */
|
|
7
|
+
id?: string;
|
|
8
|
+
label: string;
|
|
9
|
+
/** Any unit, as long as every element uses the same one. Negative and non-finite values count as 0. */
|
|
10
|
+
value: number;
|
|
11
|
+
/** Defaults to `barMarkTones[index % 6]`. */
|
|
12
|
+
tone?: BarMarkTone;
|
|
13
|
+
/** A host colour for this segment; wins over `tone`. */
|
|
14
|
+
color?: string;
|
|
15
|
+
/** Amount shown after the label in the legend: host-formatted text, such as `12.4 GB`, or a live figure. */
|
|
16
|
+
detail?: string | BarMarkFigure;
|
|
17
|
+
}
|
|
18
|
+
/** A legend amount that can change while the bar is shown: formatted with `options` between `prefix` and `suffix`. `null` reads as unknown. */
|
|
19
|
+
export type BarMarkFigure = Figure;
|
|
20
|
+
/**
|
|
21
|
+
* Draws a live legend figure. The bar-mark entry imports no animation engine, so without a renderer a figure is drawn
|
|
22
|
+
* formatted, without movement. `TokenActionBlock` supplies one that moves place by place through `AnimatedNumberReadout`,
|
|
23
|
+
* and a host that installs the animated-number peers can do the same around its own `BarMark`.
|
|
24
|
+
*/
|
|
25
|
+
export type BarMarkFigureRenderer = (figure: BarMarkFigure, props: {
|
|
26
|
+
testID?: string;
|
|
27
|
+
}) => React.ReactNode;
|
|
28
|
+
export declare const BarMarkFigureContext: React.Context<BarMarkFigureRenderer | null>;
|
|
29
|
+
export interface BarMarkProps {
|
|
30
|
+
title: string;
|
|
31
|
+
/** 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. */
|
|
32
|
+
description?: React.ReactNode;
|
|
33
|
+
elements: readonly BarMarkElement[];
|
|
34
|
+
/** The whole the bar measures against. When it is larger than the sum of the values the rest is the empty track. */
|
|
35
|
+
total?: number;
|
|
36
|
+
/** `false` hides the legend; the card then reads the elements as one label. */
|
|
37
|
+
legend?: boolean;
|
|
38
|
+
/** `small` draws a 12 unit bar for a secondary breakdown; the default is 24. */
|
|
39
|
+
size?: 'default' | 'small';
|
|
40
|
+
/** Set false to draw no card: no surface fill, padding or radius. The title row, bar and legend keep their spacing. Default `true`. */
|
|
41
|
+
surface?: boolean;
|
|
42
|
+
testID?: string;
|
|
43
|
+
}
|
|
44
|
+
/** The order segments take their colour in when an element names neither `tone` nor `color`. */
|
|
45
|
+
export declare const barMarkTones: readonly BarMarkTone[];
|
|
46
|
+
/** Each element's clamped value and its share of the whole, plus the unfilled remainder in the same unit. */
|
|
47
|
+
export declare function barMarkShares(elements: readonly BarMarkElement[], total?: number): {
|
|
48
|
+
values: number[];
|
|
49
|
+
shares: number[];
|
|
50
|
+
rest: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* One horizontally stacked bar on a card: the title leads and the description trails, the bar splits into a segment per
|
|
54
|
+
* element in proportion to its value, and a legend names each colour. The bar is decorative; each legend item reads its
|
|
55
|
+
* label, detail and share. Layout follows the provider's direction.
|
|
56
|
+
*/
|
|
57
|
+
export declare function BarMark({ title, description, elements, total, legend, size, surface, testID }: BarMarkProps): React.JSX.Element;
|