@bloxwap/hig 0.6.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/chart/README.md +13 -2
- package/chart/dist/altimeter-burst.d.ts +4 -0
- package/chart/dist/altimeter-burst.js +43 -0
- package/chart/dist/altimeter-chart.d.ts +52 -0
- package/chart/dist/altimeter-chart.js +275 -0
- package/chart/dist/altimeter-model.d.ts +43 -0
- package/chart/dist/altimeter-model.js +148 -0
- package/chart/dist/altimeter-targets.d.ts +33 -0
- package/chart/dist/altimeter-targets.js +88 -0
- package/chart/dist/bitcoin-price.d.ts +8 -0
- package/chart/dist/bitcoin-price.js +41 -0
- package/chart/dist/champions-league.d.ts +19 -0
- package/chart/dist/champions-league.js +104 -0
- package/chart/dist/index.d.ts +6 -0
- package/chart/dist/index.js +5 -0
- package/chart/dist/outcome-chart.d.ts +37 -0
- package/chart/dist/outcome-chart.js +212 -0
- package/chart/dist/outcome-model.d.ts +43 -0
- package/chart/dist/outcome-model.js +71 -0
- package/chart/dist/plus-grid.d.ts +6 -0
- package/chart/dist/plus-grid.js +29 -0
- package/contracts/README.md +1 -1
- package/contracts/dist/avatar.d.ts +68 -0
- package/contracts/dist/avatar.js +93 -0
- package/contracts/dist/confetti.d.ts +174 -0
- package/contracts/dist/confetti.js +138 -0
- package/contracts/dist/decimal.d.ts +7 -0
- package/contracts/dist/decimal.js +35 -0
- package/contracts/dist/index.d.ts +45 -2
- package/contracts/dist/index.js +145 -4
- package/contracts/dist/invariants.d.ts +17 -0
- package/contracts/dist/invariants.js +24 -0
- package/contracts/dist/messages.d.ts +62 -2
- package/contracts/dist/messages.js +22 -2
- package/contracts/dist/number-flow.d.ts +90 -0
- package/contracts/dist/number-flow.js +150 -0
- package/contracts/dist/qr.d.ts +151 -0
- package/contracts/dist/qr.js +581 -0
- package/contracts/dist/toast.d.ts +168 -0
- package/contracts/dist/toast.js +171 -0
- package/feedback/README.md +1 -1
- package/feedback/dist/contract.js +1 -1
- package/feedback/dist/react.js +2 -4
- package/native/README.md +6 -1
- package/native/dist/account-block.d.ts +62 -7
- package/native/dist/account-block.js +54 -11
- package/native/dist/animated-number-model.d.ts +47 -1
- package/native/dist/animated-number-model.js +248 -21
- package/native/dist/animated-number.d.ts +41 -1
- package/native/dist/animated-number.js +165 -17
- package/native/dist/announce.d.ts +2 -0
- package/native/dist/announce.js +10 -0
- package/native/dist/asset-balance-row.d.ts +19 -1
- package/native/dist/asset-balance-row.js +24 -8
- package/native/dist/assets-block.d.ts +115 -0
- package/native/dist/assets-block.js +87 -0
- package/native/dist/async-result.d.ts +2 -0
- package/native/dist/async-result.js +11 -0
- package/native/dist/avatar-frame.d.ts +29 -0
- package/native/dist/avatar-frame.js +56 -0
- package/native/dist/avatar.d.ts +21 -0
- package/native/dist/avatar.js +31 -0
- package/native/dist/bar-mark.d.ts +16 -2
- package/native/dist/bar-mark.js +23 -7
- package/native/dist/bar-pnl.js +7 -5
- package/native/dist/blocks.d.ts +13 -14
- package/native/dist/blocks.js +10 -6
- package/native/dist/brand.js +2 -1
- package/native/dist/button.d.ts +7 -2
- package/native/dist/button.js +16 -4
- package/native/dist/checkbox.js +2 -1
- package/native/dist/confetti.d.ts +33 -0
- package/native/dist/confetti.js +143 -0
- package/native/dist/confirm-block.d.ts +98 -0
- package/native/dist/confirm-block.js +48 -0
- package/native/dist/data.d.ts +1 -1
- package/native/dist/data.js +8 -4
- package/native/dist/explainer-block.d.ts +91 -0
- package/native/dist/explainer-block.js +34 -0
- package/native/dist/field.d.ts +19 -5
- package/native/dist/field.js +56 -9
- package/native/dist/figure.d.ts +23 -0
- package/native/dist/figure.js +10 -0
- package/native/dist/gesture-sheet-model.d.ts +50 -0
- package/native/dist/gesture-sheet-model.js +105 -0
- package/native/dist/gesture-sheet-next.d.ts +82 -0
- package/native/dist/gesture-sheet-next.js +315 -0
- package/native/dist/gesture-sheet.d.ts +5 -1
- package/native/dist/gesture-sheet.js +13 -6
- package/native/dist/icons.d.ts +9 -6
- package/native/dist/icons.js +25 -24
- package/native/dist/language-block.d.ts +14 -1
- package/native/dist/language-block.js +11 -4
- package/native/dist/list-group.d.ts +44 -8
- package/native/dist/list-group.js +84 -13
- package/native/dist/manage-position-block.d.ts +35 -2
- package/native/dist/manage-position-block.js +41 -11
- package/native/dist/market-row.d.ts +46 -0
- package/native/dist/market-row.js +41 -0
- package/native/dist/navigation.js +5 -3
- package/native/dist/notifications-block.d.ts +30 -2
- package/native/dist/notifications-block.js +16 -8
- package/native/dist/number-format.d.ts +6 -0
- package/native/dist/number-format.js +9 -0
- package/native/dist/pickers.d.ts +32 -2
- package/native/dist/pickers.js +17 -9
- package/native/dist/position-block.d.ts +66 -10
- package/native/dist/position-block.js +45 -11
- package/native/dist/preset-group.d.ts +31 -0
- package/native/dist/preset-group.js +39 -0
- package/native/dist/preset-picker-block.d.ts +107 -0
- package/native/dist/preset-picker-block.js +43 -0
- package/native/dist/profile-block.d.ts +38 -5
- package/native/dist/profile-block.js +31 -6
- package/native/dist/provider.d.ts +14 -5
- package/native/dist/provider.js +32 -6
- package/native/dist/qr-code.d.ts +33 -0
- package/native/dist/qr-code.js +29 -0
- package/native/dist/radio-group.d.ts +23 -5
- package/native/dist/radio-group.js +40 -12
- package/native/dist/recipes.d.ts +6 -0
- package/native/dist/recipes.js +6 -0
- package/native/dist/reward-block.d.ts +55 -13
- package/native/dist/reward-block.js +37 -14
- package/native/dist/screen-header.d.ts +59 -0
- package/native/dist/screen-header.js +37 -0
- package/native/dist/select.js +4 -2
- package/native/dist/selection.d.ts +3 -2
- package/native/dist/selection.js +1 -0
- package/native/dist/setting-header.d.ts +2 -8
- package/native/dist/setting-header.js +2 -11
- package/native/dist/setting-switch.d.ts +15 -2
- package/native/dist/setting-switch.js +11 -4
- package/native/dist/signals-block.d.ts +26 -2
- package/native/dist/signals-block.js +14 -4
- package/native/dist/slider.js +5 -1
- package/native/dist/sound-haptics-block.d.ts +29 -2
- package/native/dist/sound-haptics-block.js +19 -8
- package/native/dist/status.d.ts +47 -14
- package/native/dist/status.js +39 -22
- package/native/dist/sticky-header.d.ts +28 -0
- package/native/dist/sticky-header.js +29 -0
- package/native/dist/surface.d.ts +3 -1
- package/native/dist/surface.js +2 -1
- package/native/dist/swap-amount-card.d.ts +57 -0
- package/native/dist/swap-amount-card.js +31 -0
- package/native/dist/swap-panel-block.d.ts +11 -4
- package/native/dist/swap-panel-block.js +67 -38
- package/native/dist/swap-parts.d.ts +5 -10
- package/native/dist/swap-parts.js +22 -24
- package/native/dist/swap-shared.d.ts +8 -2
- package/native/dist/swap-shared.js +10 -6
- package/native/dist/swap-views.js +6 -4
- 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 +40 -7
- package/native/dist/target-block.js +31 -11
- package/native/dist/toast.d.ts +47 -0
- package/native/dist/toast.js +386 -0
- package/native/dist/token-action-block.d.ts +26 -9
- package/native/dist/token-action-block.js +21 -8
- package/native/dist/trade-history-detail-block.d.ts +26 -1
- package/native/dist/trade-history-detail-block.js +17 -9
- package/native/dist/trade-history-list-block.d.ts +71 -5
- package/native/dist/trade-history-list-block.js +55 -17
- package/native/dist/wallet-address-core.d.ts +25 -0
- package/native/dist/wallet-address-core.js +34 -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 +131 -2
- package/react/README.md +3 -1
- package/react/dist/animated-number-flow.d.ts +72 -0
- package/react/dist/animated-number-flow.js +316 -0
- package/react/dist/animated-number-model.d.ts +24 -0
- package/react/dist/animated-number-model.js +106 -3
- package/react/dist/animated-number.d.ts +49 -1
- package/react/dist/animated-number.js +146 -11
- package/react/dist/asset-balance-row.d.ts +19 -1
- package/react/dist/asset-balance-row.js +17 -3
- package/react/dist/async-result.d.ts +2 -0
- package/react/dist/async-result.js +11 -0
- package/react/dist/avatar.d.ts +25 -0
- package/react/dist/avatar.js +50 -0
- package/react/dist/bar-mark.d.ts +5 -2
- package/react/dist/bar-mark.js +5 -3
- package/react/dist/blocks/account-block.d.ts +57 -7
- package/react/dist/blocks/account-block.js +51 -11
- package/react/dist/blocks/assets-block.d.ts +106 -0
- package/react/dist/blocks/assets-block.js +135 -0
- package/react/dist/blocks/confirm-block.d.ts +91 -0
- package/react/dist/blocks/confirm-block.js +31 -0
- package/react/dist/blocks/explainer-block.d.ts +80 -0
- package/react/dist/blocks/explainer-block.js +20 -0
- package/react/dist/blocks/install-command.js +3 -1
- package/react/dist/blocks/language-block.d.ts +9 -1
- package/react/dist/blocks/language-block.js +8 -6
- package/react/dist/blocks/manage-position-block.d.ts +30 -2
- package/react/dist/blocks/manage-position-block.js +23 -4
- package/react/dist/blocks/market-row.d.ts +20 -9
- package/react/dist/blocks/market-row.js +17 -4
- package/react/dist/blocks/notifications-block.d.ts +27 -2
- package/react/dist/blocks/notifications-block.js +11 -2
- package/react/dist/blocks/pickers.d.ts +30 -1
- package/react/dist/blocks/pickers.js +32 -10
- package/react/dist/blocks/position-block.d.ts +34 -11
- package/react/dist/blocks/position-block.js +16 -5
- package/react/dist/blocks/preset-picker-block.d.ts +85 -0
- package/react/dist/blocks/preset-picker-block.js +19 -0
- package/react/dist/blocks/profile-block.d.ts +33 -6
- package/react/dist/blocks/profile-block.js +31 -6
- package/react/dist/blocks/reward-block.d.ts +65 -21
- package/react/dist/blocks/reward-block.js +24 -11
- package/react/dist/blocks/screen-header.d.ts +34 -2
- package/react/dist/blocks/screen-header.js +17 -6
- package/react/dist/blocks/setting-switch.d.ts +14 -1
- package/react/dist/blocks/setting-switch.js +11 -4
- package/react/dist/blocks/signals-block.d.ts +23 -2
- package/react/dist/blocks/signals-block.js +6 -5
- package/react/dist/blocks/sound-haptics-block.d.ts +27 -3
- package/react/dist/blocks/sound-haptics-block.js +11 -7
- package/react/dist/blocks/sticky-header.d.ts +19 -0
- package/react/dist/blocks/sticky-header.js +103 -0
- package/react/dist/blocks/swap/amount-card.js +2 -1
- package/react/dist/blocks/swap/settings.js +4 -3
- package/react/dist/blocks/swap/shared.d.ts +29 -23
- package/react/dist/blocks/swap/shared.js +36 -32
- package/react/dist/blocks/swap-panel-block.d.ts +12 -3
- package/react/dist/blocks/swap-panel-block.js +72 -37
- package/react/dist/blocks/target-block.d.ts +35 -7
- package/react/dist/blocks/target-block.js +26 -12
- package/react/dist/blocks/token-action-block.d.ts +21 -8
- package/react/dist/blocks/token-action-block.js +9 -6
- package/react/dist/blocks/trade-history-detail-block.d.ts +23 -1
- package/react/dist/blocks/trade-history-detail-block.js +5 -4
- package/react/dist/blocks/trade-history-list-block.d.ts +31 -5
- package/react/dist/blocks/trade-history-list-block.js +20 -10
- package/react/dist/blocks.d.ts +12 -8
- package/react/dist/blocks.js +6 -2
- package/react/dist/brand.js +2 -1
- package/react/dist/button.d.ts +9 -3
- package/react/dist/button.js +12 -5
- package/react/dist/confetti.d.ts +27 -0
- package/react/dist/confetti.js +240 -0
- package/react/dist/data.js +11 -4
- package/react/dist/field.d.ts +20 -5
- package/react/dist/field.js +30 -8
- package/react/dist/figure.d.ts +23 -0
- package/react/dist/figure.js +12 -0
- package/react/dist/gesture-sheet.d.ts +15 -1
- package/react/dist/gesture-sheet.js +53 -8
- package/react/dist/list-group.d.ts +41 -8
- package/react/dist/list-group.js +49 -13
- package/react/dist/navigation.js +11 -3
- package/react/dist/overlay.d.ts +28 -3
- package/react/dist/overlay.js +29 -3
- package/react/dist/preset-group.d.ts +30 -0
- package/react/dist/preset-group.js +13 -0
- package/react/dist/provider.d.ts +42 -5
- package/react/dist/provider.js +84 -10
- package/react/dist/qr-code.d.ts +32 -0
- package/react/dist/qr-code.js +28 -0
- package/react/dist/select.js +10 -3
- package/react/dist/selection.d.ts +18 -4
- package/react/dist/selection.js +20 -10
- package/react/dist/slider.js +5 -1
- package/react/dist/status.d.ts +14 -10
- package/react/dist/status.js +17 -9
- package/react/dist/styles.css +380 -150
- package/react/dist/surface.d.ts +5 -1
- package/react/dist/surface.js +1 -1
- package/react/dist/toast.d.ts +19 -12
- package/react/dist/toast.js +29 -7
- package/react/dist/wallet-address-core.d.ts +27 -0
- package/react/dist/wallet-address-core.js +29 -0
- package/react/dist/wallet-address.d.ts +6 -12
- package/react/dist/wallet-address.js +5 -16
- package/tokens/README.md +2 -2
- package/tokens/dist/index.d.ts +16 -0
- package/tokens/dist/index.js +16 -0
- package/tokens/dist/manifest.json +8 -0
- package/tokens/dist/tokens.css +6 -0
|
@@ -19,15 +19,56 @@ 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
|
-
/**
|
|
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;
|
|
38
|
+
/**
|
|
39
|
+
* Display only. Keep raw decimal strings in transaction logic. A `signDisplay` the runtime's Intl ignores (Hermes on iOS draws
|
|
40
|
+
* `12.34%` for `exceptZero`) is composed by {@link formatSignedNumber}, so every engine draws the same string; engines whose Intl
|
|
41
|
+
* honours it format exactly as before.
|
|
42
|
+
*/
|
|
23
43
|
export declare function formatNumber(value: number | null | undefined, locale?: string, options?: Intl.NumberFormatOptions): string;
|
|
44
|
+
/** `Intl.NumberFormatOptions['signDisplay']`, with ES2023's `negative`, which the TypeScript lib in use may not list. */
|
|
45
|
+
export type SignDisplay = NonNullable<Intl.NumberFormatOptions['signDisplay']> | 'negative';
|
|
46
|
+
/** Whether this runtime's `Intl.NumberFormat` draws `signDisplay` (each mode is checked once, in decimal, currency and percent). */
|
|
47
|
+
export declare function intlSignDisplaySupported(mode: SignDisplay): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* `Intl.NumberFormat` with `signDisplay`, composed without asking Intl to draw the sign: the magnitude and the locale's own negative
|
|
50
|
+
* form are formatted with `signDisplay` left out, and a plus takes the minus sign's place, so the sign keeps its side of the currency
|
|
51
|
+
* sign, percent sign and digits and any bidi marks around it (`+$12.50`, `12,50 $` → `+12,50 $`, `$+12.50` in de-CH, `+١٢` in
|
|
52
|
+
* Arabic). Zero follows the rounded figure: `exceptZero` draws `0.00` for 0.001 at two places, as Intl does. Where the negative form
|
|
53
|
+
* has no minus (accounting parentheses), the locale's plus leads the positive form. Matches ICU's output for decimal, currency,
|
|
54
|
+
* percent, unit and compact formats; display only.
|
|
55
|
+
*/
|
|
56
|
+
export declare function formatSignedNumber(value: number | null | undefined, locale?: string, options?: Intl.NumberFormatOptions): string;
|
|
24
57
|
/** Leverage multiplier display (`10×`). Never percent-styled; the `×` suffix is untranslated. Unknown → `—`. */
|
|
25
58
|
export declare function formatLeverage(value: number | null | undefined, locale?: string, options?: Intl.NumberFormatOptions): string;
|
|
26
59
|
/** Amount followed by an untranslated ticker such as `USDC` (not an ISO 4217 currency), joined by a no-break space. Unknown → `—`. */
|
|
27
60
|
export declare function formatTicker(value: number | null | undefined, ticker: string, locale?: string, options?: Intl.NumberFormatOptions): string;
|
|
28
61
|
/** Clock display for funding and other protocol instants. The host must name the zone; the zone name is always shown. Unknown → `—`. */
|
|
29
62
|
export declare function formatZonedTime(value: Date | number | null | undefined, locale: string, timeZone: string, options?: Intl.DateTimeFormatOptions): string;
|
|
30
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Time left until a market opens, rounded up to the second. `visible` is a clock: `2:14:33`, or `1d 04:12:09` past a day.
|
|
65
|
+
* `spoken` names the largest units in words without seconds (`2 hours, 14 minutes`), so it changes once a minute and is
|
|
66
|
+
* calm in an accessible name; under a minute it reads the seconds. Negative time reads as zero.
|
|
67
|
+
*/
|
|
68
|
+
export declare function formatCountdown(remainingMs: number, locale?: string): {
|
|
69
|
+
visible: string;
|
|
70
|
+
spoken: string;
|
|
71
|
+
};
|
|
31
72
|
export interface FontManifest {
|
|
32
73
|
version: string;
|
|
33
74
|
faces: ReadonlyArray<{
|
|
@@ -39,3 +80,5 @@ export interface FontManifest {
|
|
|
39
80
|
}>;
|
|
40
81
|
}
|
|
41
82
|
export declare function nativeFont(manifest: FontManifest, family: string, weight: number, script?: string): string;
|
|
83
|
+
export { assertUniqueKeys, numericRange, progressValue, paginationValue } from './invariants.js';
|
|
84
|
+
export { decimal, decimalMultiply, decimalDivide, decimalCompare, localizeDecimal } from './decimal.js';
|
package/contracts/dist/index.js
CHANGED
|
@@ -23,9 +23,111 @@ 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
|
-
/**
|
|
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
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Display only. Keep raw decimal strings in transaction logic. A `signDisplay` the runtime's Intl ignores (Hermes on iOS draws
|
|
50
|
+
* `12.34%` for `exceptZero`) is composed by {@link formatSignedNumber}, so every engine draws the same string; engines whose Intl
|
|
51
|
+
* honours it format exactly as before.
|
|
52
|
+
*/
|
|
27
53
|
export function formatNumber(value, locale = 'en-US', options = {}) {
|
|
28
|
-
|
|
54
|
+
if (value == null || !Number.isFinite(value))
|
|
55
|
+
return '—';
|
|
56
|
+
const sign = options.signDisplay;
|
|
57
|
+
try {
|
|
58
|
+
return sign !== undefined && sign !== 'auto' && !intlSignDisplaySupported(sign) ? formatSignedNumber(value, locale, options) : new Intl.NumberFormat(locale, options).format(value);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return '—';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const signSupport = new Map();
|
|
65
|
+
/** Whether this runtime's `Intl.NumberFormat` draws `signDisplay` (each mode is checked once, in decimal, currency and percent). */
|
|
66
|
+
export function intlSignDisplaySupported(mode) {
|
|
67
|
+
const known = signSupport.get(mode);
|
|
68
|
+
if (known !== undefined)
|
|
69
|
+
return known;
|
|
70
|
+
const expected = {
|
|
71
|
+
always: [[1, '+1', '+$1.00', '+100%'], [0, '+0', '+$0.00', '+0%'], [-1, '-1', '-$1.00', '-100%']],
|
|
72
|
+
exceptZero: [[1, '+1', '+$1.00', '+100%'], [0, '0', '$0.00', '0%'], [-0, '0', '$0.00', '0%'], [-1, '-1', '-$1.00', '-100%']],
|
|
73
|
+
negative: [[1, '1', '$1.00', '100%'], [-0, '0', '$0.00', '0%'], [-1, '-1', '-$1.00', '-100%']],
|
|
74
|
+
never: [[1, '1', '$1.00', '100%'], [-1, '1', '$1.00', '100%']],
|
|
75
|
+
};
|
|
76
|
+
let supported = false;
|
|
77
|
+
try {
|
|
78
|
+
const cases = expected[mode];
|
|
79
|
+
if (cases) {
|
|
80
|
+
const signed = (options) => new Intl.NumberFormat('en-US', { ...options, signDisplay: mode });
|
|
81
|
+
const decimal = signed({}), money = signed({ style: 'currency', currency: 'USD' }), share = signed({ style: 'percent' });
|
|
82
|
+
supported = cases.every(([value, plain, usd, percent]) => decimal.format(value) === plain && money.format(value) === usd && share.format(value) === percent);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
supported = false;
|
|
87
|
+
}
|
|
88
|
+
signSupport.set(mode, supported);
|
|
89
|
+
return supported;
|
|
90
|
+
}
|
|
91
|
+
const minusSign = /[-−‐-―﹣-]/u;
|
|
92
|
+
/**
|
|
93
|
+
* `Intl.NumberFormat` with `signDisplay`, composed without asking Intl to draw the sign: the magnitude and the locale's own negative
|
|
94
|
+
* form are formatted with `signDisplay` left out, and a plus takes the minus sign's place, so the sign keeps its side of the currency
|
|
95
|
+
* sign, percent sign and digits and any bidi marks around it (`+$12.50`, `12,50 $` → `+12,50 $`, `$+12.50` in de-CH, `+١٢` in
|
|
96
|
+
* Arabic). Zero follows the rounded figure: `exceptZero` draws `0.00` for 0.001 at two places, as Intl does. Where the negative form
|
|
97
|
+
* has no minus (accounting parentheses), the locale's plus leads the positive form. Matches ICU's output for decimal, currency,
|
|
98
|
+
* percent, unit and compact formats; display only.
|
|
99
|
+
*/
|
|
100
|
+
export function formatSignedNumber(value, locale = 'en-US', options = {}) {
|
|
101
|
+
if (value == null || !Number.isFinite(value))
|
|
102
|
+
return '—';
|
|
103
|
+
const { signDisplay: requested, ...rest } = options, signDisplay = requested;
|
|
104
|
+
let formatter;
|
|
105
|
+
try {
|
|
106
|
+
formatter = new Intl.NumberFormat(locale, rest);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return '—';
|
|
110
|
+
}
|
|
111
|
+
if (signDisplay === undefined || signDisplay === 'auto')
|
|
112
|
+
return formatter.format(value);
|
|
113
|
+
const magnitude = Math.abs(value), negative = value < 0 || Object.is(value, -0), absolute = formatter.format(magnitude), zero = absolute === formatter.format(0);
|
|
114
|
+
const plus = () => {
|
|
115
|
+
const minus = formatter.format(-magnitude), at = minus.search(minusSign);
|
|
116
|
+
if (at >= 0)
|
|
117
|
+
return `${minus.slice(0, at)}+${minus.slice(at + 1)}`;
|
|
118
|
+
const digits = new Intl.NumberFormat(locale, { maximumFractionDigits: 0, useGrouping: false }), sign = digits.format(-1).replace(digits.format(1), '');
|
|
119
|
+
return `${minusSign.test(sign) ? sign.replace(minusSign, '+') : '+'}${absolute}`;
|
|
120
|
+
};
|
|
121
|
+
switch (signDisplay) {
|
|
122
|
+
case 'never': {
|
|
123
|
+
const { currencySign, ...plain } = rest;
|
|
124
|
+
return currencySign === undefined ? absolute : new Intl.NumberFormat(locale, plain).format(magnitude);
|
|
125
|
+
}
|
|
126
|
+
case 'negative': return negative && !zero ? formatter.format(-magnitude) : absolute;
|
|
127
|
+
case 'exceptZero': return zero ? absolute : negative ? formatter.format(-magnitude) : plus();
|
|
128
|
+
case 'always': return negative ? formatter.format(-magnitude) : plus();
|
|
129
|
+
default: return formatter.format(value);
|
|
130
|
+
}
|
|
29
131
|
}
|
|
30
132
|
/** Leverage multiplier display (`10×`). Never percent-styled; the `×` suffix is untranslated. Unknown → `—`. */
|
|
31
133
|
export function formatLeverage(value, locale = 'en-US', options = { maximumFractionDigits: 2 }) {
|
|
@@ -40,9 +142,46 @@ export function formatTicker(value, ticker, locale = 'en-US', options = {}) {
|
|
|
40
142
|
/** Clock display for funding and other protocol instants. The host must name the zone; the zone name is always shown. Unknown → `—`. */
|
|
41
143
|
export function formatZonedTime(value, locale, timeZone, options = { hour: 'numeric', minute: '2-digit' }) {
|
|
42
144
|
const time = value instanceof Date ? value.getTime() : value;
|
|
43
|
-
if (time == null || !Number.isFinite(time))
|
|
145
|
+
if (time == null || !Number.isFinite(time) || Math.abs(time) > 8640000000000000)
|
|
146
|
+
return '—';
|
|
147
|
+
try {
|
|
148
|
+
return new Intl.DateTimeFormat(locale, { timeZoneName: 'short', ...options, timeZone }).format(time);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
44
151
|
return '—';
|
|
45
|
-
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/** Font 0.1.2 publishes CSS/Next loaders, native faces are derived by the optional pinned HIG font generator. */
|
|
155
|
+
/** Formats one unit with Intl (`2 hours`, `1d`), falling back to plain digits and the unit name where the runtime lacks unit formatting. */
|
|
156
|
+
function formatUnit(value, unit, locale, unitDisplay) {
|
|
157
|
+
try {
|
|
158
|
+
return new Intl.NumberFormat(locale, { style: 'unit', unit, unitDisplay }).format(value);
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
return unitDisplay === 'narrow' ? `${value}${unit[0]}` : `${value} ${unit}${value === 1 ? '' : 's'}`;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Time left until a market opens, rounded up to the second. `visible` is a clock: `2:14:33`, or `1d 04:12:09` past a day.
|
|
166
|
+
* `spoken` names the largest units in words without seconds (`2 hours, 14 minutes`), so it changes once a minute and is
|
|
167
|
+
* calm in an accessible name; under a minute it reads the seconds. Negative time reads as zero.
|
|
168
|
+
*/
|
|
169
|
+
export function formatCountdown(remainingMs, locale = 'en-US') {
|
|
170
|
+
if (!Number.isFinite(remainingMs))
|
|
171
|
+
return { visible: '—', spoken: '—' };
|
|
172
|
+
const total = Math.max(0, Math.ceil(remainingMs / 1000));
|
|
173
|
+
const days = Math.floor(total / 86400), hours = Math.floor(total % 86400 / 3600), minutes = Math.floor(total % 3600 / 60), seconds = total % 60;
|
|
174
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
175
|
+
const visible = days > 0 ? `${formatUnit(days, 'day', locale, 'narrow')} ${pad(hours)}:${pad(minutes)}:${pad(seconds)}` : `${hours}:${pad(minutes)}:${pad(seconds)}`;
|
|
176
|
+
const words = total < 60 ? [formatUnit(seconds, 'second', locale, 'long')] : [days ? formatUnit(days, 'day', locale, 'long') : '', hours ? formatUnit(hours, 'hour', locale, 'long') : '', minutes ? formatUnit(minutes, 'minute', locale, 'long') : ''].filter(Boolean);
|
|
177
|
+
let spoken;
|
|
178
|
+
try {
|
|
179
|
+
spoken = new Intl.ListFormat(locale, { style: 'narrow', type: 'unit' }).format(words);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
spoken = words.join(', ');
|
|
183
|
+
}
|
|
184
|
+
return { visible, spoken };
|
|
46
185
|
}
|
|
47
186
|
export function nativeFont(manifest, family, weight, script = 'latin') {
|
|
48
187
|
const face = manifest.faces.find(f => f.family === family && f.weight === weight && f.script === script);
|
|
@@ -50,3 +189,5 @@ export function nativeFont(manifest, family, weight, script = 'latin') {
|
|
|
50
189
|
throw new Error(`Register a pinned ${family} ${weight} ${script} native face`);
|
|
51
190
|
return face.registration ?? face.family;
|
|
52
191
|
}
|
|
192
|
+
export { assertUniqueKeys, numericRange, progressValue, paginationValue } from './invariants.js';
|
|
193
|
+
export { decimal, decimalMultiply, decimalDivide, decimalCompare, localizeDecimal } from './decimal.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Identity must not collapse two rows into one stateful element. */
|
|
2
|
+
export declare function assertUniqueKeys<T>(items: readonly T[], key: (item: T) => string | number, label?: string): void;
|
|
3
|
+
/** Shared finite range for visuals, accessibility and emitted values. */
|
|
4
|
+
export declare function numericRange(min?: number, max?: number, step?: number): {
|
|
5
|
+
min: number;
|
|
6
|
+
max: number;
|
|
7
|
+
step: number;
|
|
8
|
+
clamp: (value: number) => number;
|
|
9
|
+
};
|
|
10
|
+
export declare function progressValue(value: number | undefined, max: number): {
|
|
11
|
+
max: number;
|
|
12
|
+
value: number | undefined;
|
|
13
|
+
};
|
|
14
|
+
export declare function paginationValue(page: number, total: number): {
|
|
15
|
+
total: number;
|
|
16
|
+
page: number;
|
|
17
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Identity must not collapse two rows into one stateful element. */
|
|
2
|
+
export function assertUniqueKeys(items, key, label = 'Collection') {
|
|
3
|
+
const seen = new Set();
|
|
4
|
+
for (const item of items) {
|
|
5
|
+
const id = String(key(item));
|
|
6
|
+
if (seen.has(id))
|
|
7
|
+
throw new Error(`${label} requires unique keys: ${id}`);
|
|
8
|
+
seen.add(id);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** Shared finite range for visuals, accessibility and emitted values. */
|
|
12
|
+
export function numericRange(min = 0, max = 100, step = 1) {
|
|
13
|
+
if (!Number.isFinite(min) || !Number.isFinite(max) || max < min || !Number.isFinite(step) || step <= 0)
|
|
14
|
+
throw new RangeError('Range requires finite min <= max and step > 0');
|
|
15
|
+
return { min, max, step, clamp: (value) => Number.isFinite(value) ? Math.min(max, Math.max(min, value)) : min };
|
|
16
|
+
}
|
|
17
|
+
export function progressValue(value, max) {
|
|
18
|
+
const ceiling = Number.isFinite(max) && max > 0 ? max : 100;
|
|
19
|
+
return { max: ceiling, value: value === undefined || !Number.isFinite(value) ? undefined : Math.min(ceiling, Math.max(0, value)) };
|
|
20
|
+
}
|
|
21
|
+
export function paginationValue(page, total) {
|
|
22
|
+
const count = Number.isFinite(total) ? Math.max(1, Math.floor(total)) : 1;
|
|
23
|
+
return { total: count, page: Number.isFinite(page) ? Math.max(1, Math.min(count, Math.floor(page))) : 1 };
|
|
24
|
+
}
|
|
@@ -26,7 +26,7 @@ export interface HIGMessages {
|
|
|
26
26
|
loadingContent: string;
|
|
27
27
|
/** List loading row. */
|
|
28
28
|
loadingItems: string;
|
|
29
|
-
/** Web
|
|
29
|
+
/** Web chart fallback: AltimeterChart and OutcomeChart while they wait for data, PriceChart while the chart engine loads. */
|
|
30
30
|
loadingChart: string;
|
|
31
31
|
/** List default empty text. */
|
|
32
32
|
noItems: string;
|
|
@@ -184,7 +184,7 @@ export interface HIGMessages {
|
|
|
184
184
|
addressCopied: string;
|
|
185
185
|
/** Visible hint under a wallet address that copies on press. */
|
|
186
186
|
tapToCopy: string;
|
|
187
|
-
/** Accessible name of a
|
|
187
|
+
/** Accessible name of a QR code (WalletAddress, QRCode). */
|
|
188
188
|
qrCode: string;
|
|
189
189
|
/** Control key legend in the swap panel's shortcut hint on non-Apple keyboards (`Ctrl K`). Apple keyboards show ⌘. */
|
|
190
190
|
swapControlKey: string;
|
|
@@ -206,12 +206,52 @@ export interface HIGMessages {
|
|
|
206
206
|
showAddress: string;
|
|
207
207
|
/** ProfileBlock: accessible name of the control that edits the profile name. */
|
|
208
208
|
editName: string;
|
|
209
|
+
/** ProfileBlock: accessible name of the avatar button when the host gives neither `avatarLabel` nor `name`. */
|
|
210
|
+
changeProfilePicture: string;
|
|
209
211
|
/** TokenActionBlock: built-in label of the `receive` action. */
|
|
210
212
|
receive: string;
|
|
211
213
|
/** TokenActionBlock: built-in label of the `stake` action. */
|
|
212
214
|
stake: string;
|
|
213
215
|
/** TokenActionBlock: built-in label of the `unstake` action. */
|
|
214
216
|
unstake: string;
|
|
217
|
+
/** SearchInput: accessible name of the clear button when the host gives no `clearLabel`. */
|
|
218
|
+
clearSearch: string;
|
|
219
|
+
/** AssetsBlock: the default heading. */
|
|
220
|
+
assets: string;
|
|
221
|
+
/** AssetsBlock: search placeholder (with a trailing ellipsis) and accessible name. */
|
|
222
|
+
searchMarkets: string;
|
|
223
|
+
/** AssetsBlock: accessible name of the category filter. */
|
|
224
|
+
marketCategories: string;
|
|
225
|
+
/** AssetsBlock: accessible name of the All / Positions / Trend control. */
|
|
226
|
+
assetsView: string;
|
|
227
|
+
/** AssetsBlock: the unfiltered category capsule and view. */
|
|
228
|
+
assetsAll: string;
|
|
229
|
+
/** AssetsBlock: the view of markets with an open position. */
|
|
230
|
+
assetsPositions: string;
|
|
231
|
+
/** AssetsBlock: the view of markets with a signal. */
|
|
232
|
+
assetsTrend: string;
|
|
233
|
+
/** AssetsBlock: a row's watch signal, read after the market. */
|
|
234
|
+
signalWatch: string;
|
|
235
|
+
/** AssetsBlock: a row's upward signal, read after the market. */
|
|
236
|
+
signalUp: string;
|
|
237
|
+
/** AssetsBlock: a row's downward signal, read after the market. */
|
|
238
|
+
signalDown: string;
|
|
239
|
+
/** AssetsBlock: empty Positions view. */
|
|
240
|
+
noPositions: string;
|
|
241
|
+
/** AssetsBlock: empty Trend view. */
|
|
242
|
+
noTrend: string;
|
|
243
|
+
/** AssetsBlock: before the countdown to when a closed legacy market opens, as in “Opens in 2:14:33”. */
|
|
244
|
+
opensIn: string;
|
|
245
|
+
/** ConfirmBlock: the default heading and confirming action. */
|
|
246
|
+
confirmSend: string;
|
|
247
|
+
/** ConfirmBlock: label of the destination address row. */
|
|
248
|
+
sendTo: string;
|
|
249
|
+
/** ConfirmBlock: label of the network row. */
|
|
250
|
+
sendNetwork: string;
|
|
251
|
+
/** ConfirmBlock: heading of the warning above the actions. */
|
|
252
|
+
sendWarningTitle: string;
|
|
253
|
+
/** ConfirmBlock: body of the warning, naming the token and the network. */
|
|
254
|
+
sendWarning: (symbol: string, network: string) => string;
|
|
215
255
|
}
|
|
216
256
|
export declare const close = "Close";
|
|
217
257
|
export declare const cancel = "Cancel";
|
|
@@ -310,11 +350,31 @@ export declare const deposit = "Deposit";
|
|
|
310
350
|
export declare const accountBalance = "Total balance";
|
|
311
351
|
export declare const showAddress = "Show account address";
|
|
312
352
|
export declare const editName = "Edit name";
|
|
353
|
+
export declare const changeProfilePicture = "Change profile picture";
|
|
313
354
|
export declare const language = "Language";
|
|
314
355
|
export declare const searchLanguages = "Search languages";
|
|
315
356
|
export declare const receive = "Receive";
|
|
316
357
|
export declare const stake = "Stake";
|
|
317
358
|
export declare const unstake = "Unstake";
|
|
359
|
+
export declare const clearSearch = "Clear search";
|
|
360
|
+
export declare const assets = "Assets";
|
|
361
|
+
export declare const searchMarkets = "Search markets";
|
|
362
|
+
export declare const marketCategories = "Market categories";
|
|
363
|
+
export declare const assetsView = "View";
|
|
364
|
+
export declare const assetsAll = "All";
|
|
365
|
+
export declare const assetsPositions = "Positions";
|
|
366
|
+
export declare const assetsTrend = "Trend";
|
|
367
|
+
export declare const signalWatch = "Watch";
|
|
368
|
+
export declare const signalUp = "Rising";
|
|
369
|
+
export declare const signalDown = "Falling";
|
|
370
|
+
export declare const noPositions = "No open positions";
|
|
371
|
+
export declare const noTrend = "No trending markets";
|
|
372
|
+
export declare const opensIn = "Opens in";
|
|
373
|
+
export declare const confirmSend = "Confirm Send";
|
|
374
|
+
export declare const sendTo = "To";
|
|
375
|
+
export declare const sendNetwork = "Network";
|
|
376
|
+
export declare const sendWarningTitle = "Double-check the address.";
|
|
377
|
+
export declare const sendWarning: (symbol: string, network: string) => string;
|
|
318
378
|
/** The complete English catalog. */
|
|
319
379
|
export declare const defaultMessages: Readonly<HIGMessages>;
|
|
320
380
|
/** Every message key, in documentation order. */
|
|
@@ -96,13 +96,33 @@ export const deposit = 'Deposit';
|
|
|
96
96
|
export const accountBalance = 'Total balance';
|
|
97
97
|
export const showAddress = 'Show account address';
|
|
98
98
|
export const editName = 'Edit name';
|
|
99
|
+
export const changeProfilePicture = 'Change profile picture';
|
|
99
100
|
export const language = 'Language';
|
|
100
101
|
export const searchLanguages = 'Search languages';
|
|
101
102
|
export const receive = 'Receive';
|
|
102
103
|
export const stake = 'Stake';
|
|
103
104
|
export const unstake = 'Unstake';
|
|
105
|
+
export const clearSearch = 'Clear search';
|
|
106
|
+
export const assets = 'Assets';
|
|
107
|
+
export const searchMarkets = 'Search markets';
|
|
108
|
+
export const marketCategories = 'Market categories';
|
|
109
|
+
export const assetsView = 'View';
|
|
110
|
+
export const assetsAll = 'All';
|
|
111
|
+
export const assetsPositions = 'Positions';
|
|
112
|
+
export const assetsTrend = 'Trend';
|
|
113
|
+
export const signalWatch = 'Watch';
|
|
114
|
+
export const signalUp = 'Rising';
|
|
115
|
+
export const signalDown = 'Falling';
|
|
116
|
+
export const noPositions = 'No open positions';
|
|
117
|
+
export const noTrend = 'No trending markets';
|
|
118
|
+
export const opensIn = 'Opens in';
|
|
119
|
+
export const confirmSend = 'Confirm Send';
|
|
120
|
+
export const sendTo = 'To';
|
|
121
|
+
export const sendNetwork = 'Network';
|
|
122
|
+
export const sendWarningTitle = 'Double-check the address.';
|
|
123
|
+
export const sendWarning = (symbol, network) => `${symbol} moves to this address on ${network} instantly — there's no clawback if the address is wrong.`;
|
|
104
124
|
/** The complete English catalog. */
|
|
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 };
|
|
125
|
+
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, assets, searchMarkets, marketCategories, assetsView, assetsAll, assetsPositions, assetsTrend, signalWatch, signalUp, signalDown, noPositions, noTrend, opensIn, confirmSend, sendTo, sendNetwork, sendWarningTitle, sendWarning };
|
|
106
126
|
/** Every message key, in documentation order. */
|
|
107
127
|
export const messageKeys = /* @__PURE__ */ Object.keys(defaultMessages);
|
|
108
128
|
/**
|
|
@@ -113,7 +133,7 @@ export const messageKeys = /* @__PURE__ */ Object.keys(defaultMessages);
|
|
|
113
133
|
export function resolveMessages(base, overrides) {
|
|
114
134
|
if (!overrides)
|
|
115
135
|
return base;
|
|
116
|
-
const formatters = ['dismissNotice', 'pageOf', 'resultCount', 'progressValue', 'reviewAssetOrder', 'amountInAsset', 'availableAmount', 'confirmOrderDescription', 'swapSelectToken', 'swapAmount', 'swapInsufficient', 'swapSlippage', 'swapFee'];
|
|
136
|
+
const formatters = ['dismissNotice', 'pageOf', 'resultCount', 'progressValue', 'reviewAssetOrder', 'amountInAsset', 'availableAmount', 'confirmOrderDescription', 'swapSelectToken', 'swapAmount', 'swapInsufficient', 'swapSlippage', 'swapFee', 'sendWarning'];
|
|
117
137
|
const resolved = { ...base };
|
|
118
138
|
for (const [key, value] of Object.entries(overrides)) {
|
|
119
139
|
if (value !== undefined && typeof value === (formatters.includes(key) ? 'function' : 'string'))
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NumberFlow's arithmetic, shared by the web and native renderers so both roll the same digits the same way: how far a place
|
|
3
|
+
* turns, which way, through how many glyphs, for how long and along which curve. Nothing here touches a DOM or a view.
|
|
4
|
+
*/
|
|
5
|
+
/** A named curve, or cubic-bezier control points `[x1, y1, x2, y2]`. `'number-flow'` is NumberFlow's own settle; `'standard'` is HIG's. */
|
|
6
|
+
export type NumberFlowEasing = 'number-flow' | 'standard' | 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | readonly [number, number, number, number];
|
|
7
|
+
/** One part of the motion: how long it takes, in milliseconds, and its curve. Either may be left to the default. */
|
|
8
|
+
export interface NumberFlowTiming {
|
|
9
|
+
duration?: number;
|
|
10
|
+
easing?: NumberFlowEasing;
|
|
11
|
+
}
|
|
12
|
+
export interface NumberFlowResolvedTiming {
|
|
13
|
+
duration: number;
|
|
14
|
+
easing: NumberFlowEasing;
|
|
15
|
+
}
|
|
16
|
+
export interface NumberFlowTimings {
|
|
17
|
+
/** Digits rolling to their new value. */
|
|
18
|
+
spin: NumberFlowResolvedTiming;
|
|
19
|
+
/** Places sliding sideways when the figure gains or loses a place. */
|
|
20
|
+
transform: NumberFlowResolvedTiming;
|
|
21
|
+
/** Places fading in and out. */
|
|
22
|
+
opacity: NumberFlowResolvedTiming;
|
|
23
|
+
}
|
|
24
|
+
/** Per-place limits, keyed by integer place (0 is the ones). `{1:{max:5}}` makes the tens of a seconds counter wrap 5 to 0. */
|
|
25
|
+
export type NumberFlowDigits = Readonly<Record<number, {
|
|
26
|
+
readonly max?: number;
|
|
27
|
+
}>>;
|
|
28
|
+
/** One digit of a figure: its stable key, its value, and its place (0 ones, 1 tens, -1 tenths; `null` outside the number, as in an exponent). */
|
|
29
|
+
export interface NumberFlowPlace {
|
|
30
|
+
key: string;
|
|
31
|
+
digit: number;
|
|
32
|
+
place: number | null;
|
|
33
|
+
}
|
|
34
|
+
/** NumberFlow's default settle, sampled at equal steps of time (number-flow, MIT). */
|
|
35
|
+
export declare const numberFlowCurve: readonly number[];
|
|
36
|
+
/** No part of the motion runs longer than this, whatever the host asks for. */
|
|
37
|
+
export declare const numberFlowMaxDuration = 3000;
|
|
38
|
+
/** NumberFlow's defaults: 900 ms on its settle for movement, 450 ms ease-out for fades. */
|
|
39
|
+
export declare const numberFlowDefaults: {
|
|
40
|
+
readonly transform: NumberFlowResolvedTiming;
|
|
41
|
+
readonly opacity: NumberFlowResolvedTiming;
|
|
42
|
+
};
|
|
43
|
+
/** The control points of a curve, or `null` for `'number-flow'`, which is sampled rather than a bezier. */
|
|
44
|
+
export declare function numberFlowBezier(easing: NumberFlowEasing): readonly [number, number, number, number] | null;
|
|
45
|
+
/** The curve as a CSS easing function, for the Web Animations API. `linear()` needs a browser from 2023; pass `sampled=false` for the nearest bezier instead. */
|
|
46
|
+
export declare function numberFlowEasingCSS(easing: NumberFlowEasing, sampled?: boolean): string;
|
|
47
|
+
/** A cubic bezier's progress at time `x` (both 0 to 1): Newton's method, then bisection where the slope is too flat. */
|
|
48
|
+
export declare function numberFlowBezierAt(points: readonly [number, number, number, number], x: number): number;
|
|
49
|
+
/**
|
|
50
|
+
* The curve as progress values at equal steps of time, first 0 and last 1. A renderer that cannot hand the curve to its
|
|
51
|
+
* animation engine (a UI-thread worklet) reads its progress from this table with `sampleNumberFlowEasing`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function numberFlowEasingSamples(easing: NumberFlowEasing): readonly number[];
|
|
54
|
+
/** Progress along a sampled curve at time `progress` (0 to 1), interpolated between the two nearest samples. */
|
|
55
|
+
export declare function sampleNumberFlowEasing(samples: readonly number[], progress: number): number;
|
|
56
|
+
/** A host timing over a fallback: a finite duration is kept within 0 and `numberFlowMaxDuration`, a known curve is kept, anything else falls back. */
|
|
57
|
+
export declare function resolveNumberFlowTiming(timing: NumberFlowTiming | undefined, fallback: NumberFlowResolvedTiming): NumberFlowResolvedTiming;
|
|
58
|
+
/**
|
|
59
|
+
* The three timings of one figure. `duration` is the shorthand: it sets how long digits roll and places slide, and fades take
|
|
60
|
+
* half of it. `transformTiming` is also the roll's timing until `spinTiming` says otherwise, as in NumberFlow.
|
|
61
|
+
*/
|
|
62
|
+
export declare function resolveNumberFlowTimings({ duration, spinTiming, transformTiming, opacityTiming }: {
|
|
63
|
+
duration?: number;
|
|
64
|
+
spinTiming?: NumberFlowTiming;
|
|
65
|
+
transformTiming?: NumberFlowTiming;
|
|
66
|
+
opacityTiming?: NumberFlowTiming;
|
|
67
|
+
}): NumberFlowTimings;
|
|
68
|
+
/** How many glyphs a place rolls through before it wraps: ten, or `max + 1` where `digits` limits an integer place, and never fewer than the digit it must show. */
|
|
69
|
+
export declare function numberFlowDigitLength(digits: NumberFlowDigits | undefined, place: number | null, digit?: number): number;
|
|
70
|
+
/**
|
|
71
|
+
* How far a place turns, in glyphs: positive rolls up to higher digits, negative down. With a trend the place keeps turning
|
|
72
|
+
* that way and wraps past its last glyph (9 to 0 going up is +1, not -9); without one it takes the short way its own digits
|
|
73
|
+
* point. `loop` turns an unchanged place once all the way round, for a figure that counts continuously.
|
|
74
|
+
*/
|
|
75
|
+
export declare function numberFlowDelta(previous: number, value: number, trend: number, length?: number, loop?: boolean): number;
|
|
76
|
+
/** The highest place that changed between two readings, in display order, or `undefined` when none did. Places at or below it loop when the figure is continuous. */
|
|
77
|
+
export declare function numberFlowLoopStart(previous: readonly NumberFlowPlace[], next: readonly NumberFlowPlace[]): number | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* The turn of every place in the new reading, by key. A place the old reading did not have starts from zero, as it does in
|
|
80
|
+
* NumberFlow. `trend` is the resolved direction of the whole change (-1, 0 or 1); places the new reading dropped are not listed.
|
|
81
|
+
*/
|
|
82
|
+
export declare function numberFlowDeltas(previous: readonly NumberFlowPlace[], next: readonly NumberFlowPlace[], { trend, digits, continuous }: {
|
|
83
|
+
trend: number;
|
|
84
|
+
digits?: NumberFlowDigits;
|
|
85
|
+
continuous?: boolean;
|
|
86
|
+
}): Map<string, number>;
|
|
87
|
+
/** The glyph index a reel shows at a position that has turned any number of times either way. */
|
|
88
|
+
export declare function numberFlowGlyph(position: number, length?: number): number;
|
|
89
|
+
/** Whether text can be drawn place by place from left to right without reordering it: no bidi controls and no right-to-left letters (Arabic-script digits are fine). */
|
|
90
|
+
export declare function numberFlowNeutral(text: string): boolean;
|