@bloxwap/hig 0.7.0 → 0.9.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 +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 +29 -2
- package/contracts/dist/index.js +123 -4
- package/contracts/dist/invariants.d.ts +17 -0
- package/contracts/dist/invariants.js +24 -0
- package/contracts/dist/login.d.ts +34 -0
- package/contracts/dist/login.js +43 -0
- package/contracts/dist/messages.d.ts +57 -3
- package/contracts/dist/messages.js +20 -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 +10 -1
- package/native/dist/account-block.js +17 -7
- package/native/dist/animated-number-model.d.ts +41 -1
- package/native/dist/animated-number-model.js +201 -23
- package/native/dist/animated-number.d.ts +39 -1
- package/native/dist/animated-number.js +164 -17
- package/native/dist/announce.d.ts +2 -0
- package/native/dist/announce.js +10 -0
- package/native/dist/asset-balance-row.d.ts +3 -1
- package/native/dist/asset-balance-row.js +15 -4
- 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 +2 -0
- package/native/dist/bar-mark.js +4 -2
- package/native/dist/bar-pnl.js +2 -1
- package/native/dist/blocks.d.ts +9 -2
- package/native/dist/blocks.js +8 -1
- package/native/dist/brand.js +2 -1
- package/native/dist/button.d.ts +7 -2
- package/native/dist/button.js +13 -3
- 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 +5 -1
- package/native/dist/deposit-block.d.ts +19 -0
- package/native/dist/deposit-block.js +17 -0
- package/native/dist/explainer-block.d.ts +91 -0
- package/native/dist/explainer-block.js +34 -0
- package/native/dist/field.d.ts +5 -1
- package/native/dist/field.js +27 -6
- 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 +10 -1
- package/native/dist/language-block.js +11 -4
- package/native/dist/list-group.d.ts +3 -1
- package/native/dist/list-group.js +26 -13
- package/native/dist/login-block.d.ts +4 -0
- package/native/dist/login-block.js +22 -0
- package/native/dist/manage-position-block.d.ts +8 -1
- package/native/dist/manage-position-block.js +7 -2
- package/native/dist/market-row.js +19 -8
- package/native/dist/navigation.js +5 -3
- package/native/dist/number-format.d.ts +6 -0
- package/native/dist/number-format.js +9 -0
- package/native/dist/pickers.d.ts +8 -0
- package/native/dist/pickers.js +3 -3
- package/native/dist/position-block.d.ts +5 -5
- 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 +10 -1
- package/native/dist/profile-block.js +8 -3
- package/native/dist/provider.d.ts +5 -2
- package/native/dist/provider.js +27 -5
- package/native/dist/qr-code.d.ts +33 -0
- package/native/dist/qr-code.js +29 -0
- package/native/dist/radio-group.d.ts +19 -7
- package/native/dist/radio-group.js +39 -10
- package/native/dist/reward-block.d.ts +10 -7
- package/native/dist/reward-block.js +9 -4
- package/native/dist/screen-header.d.ts +13 -3
- package/native/dist/screen-header.js +12 -4
- package/native/dist/select.js +4 -2
- package/native/dist/selection.d.ts +2 -1
- package/native/dist/selection.js +1 -0
- package/native/dist/setting-switch.d.ts +1 -1
- package/native/dist/setting-switch.js +7 -3
- package/native/dist/slider.js +5 -1
- package/native/dist/sound-haptics-block.js +1 -1
- package/native/dist/status.d.ts +41 -9
- package/native/dist/status.js +34 -17
- package/native/dist/sticky-header.js +9 -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 → swap-block.d.ts} +18 -8
- package/native/dist/{swap-panel-block.js → swap-block.js} +63 -35
- package/native/dist/swap-parts.d.ts +3 -10
- package/native/dist/swap-parts.js +22 -24
- package/native/dist/swap-shared.d.ts +2 -2
- package/native/dist/swap-shared.js +10 -6
- package/native/dist/swap-sheet.d.ts +3 -3
- package/native/dist/swap-sheet.js +3 -3
- package/native/dist/swap-views.js +1 -1
- package/native/dist/target-block.d.ts +7 -1
- package/native/dist/target-block.js +13 -6
- package/native/dist/toast.d.ts +47 -0
- package/native/dist/toast.js +386 -0
- package/native/dist/token-action-block.d.ts +11 -2
- package/native/dist/token-action-block.js +10 -4
- package/native/dist/trade-history-list-block.js +7 -4
- package/native/dist/wallet-address-core.js +6 -3
- package/native-fonts/README.md +1 -1
- package/og-fonts/README.md +1 -1
- package/package.json +155 -11
- 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 +18 -0
- package/react/dist/animated-number-model.js +75 -5
- package/react/dist/animated-number.d.ts +45 -1
- package/react/dist/animated-number.js +137 -6
- package/react/dist/asset-balance-row.d.ts +3 -1
- package/react/dist/asset-balance-row.js +10 -4
- 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/blocks/account-block.d.ts +5 -1
- package/react/dist/blocks/account-block.js +11 -6
- 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/deposit-block.d.ts +19 -0
- package/react/dist/blocks/deposit-block.js +15 -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 +5 -1
- package/react/dist/blocks/language-block.js +4 -3
- package/react/dist/blocks/login-block.d.ts +4 -0
- package/react/dist/blocks/login-block.js +14 -0
- package/react/dist/blocks/manage-position-block.d.ts +3 -1
- package/react/dist/blocks/manage-position-block.js +2 -2
- package/react/dist/blocks/market-row.js +8 -3
- package/react/dist/blocks/notifications-block.d.ts +3 -1
- package/react/dist/blocks/notifications-block.js +2 -2
- package/react/dist/blocks/pickers.d.ts +9 -0
- package/react/dist/blocks/pickers.js +4 -2
- package/react/dist/blocks/position-block.d.ts +3 -3
- 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 +5 -1
- package/react/dist/blocks/profile-block.js +12 -13
- package/react/dist/blocks/reward-block.d.ts +13 -8
- package/react/dist/blocks/reward-block.js +7 -4
- package/react/dist/blocks/screen-header.d.ts +10 -2
- package/react/dist/blocks/screen-header.js +7 -4
- package/react/dist/blocks/setting-switch.js +6 -3
- package/react/dist/blocks/signals-block.d.ts +3 -1
- package/react/dist/blocks/signals-block.js +4 -3
- package/react/dist/blocks/sound-haptics-block.d.ts +3 -1
- package/react/dist/blocks/sound-haptics-block.js +2 -2
- package/react/dist/blocks/sticky-header.d.ts +14 -4
- package/react/dist/blocks/sticky-header.js +68 -8
- package/react/dist/blocks/swap/settings.js +2 -1
- package/react/dist/blocks/swap/shared.d.ts +22 -22
- package/react/dist/blocks/swap/shared.js +30 -28
- package/react/dist/blocks/{swap-panel-block.d.ts → swap-block.d.ts} +19 -8
- package/react/dist/blocks/swap-block.js +215 -0
- package/react/dist/blocks/swap-sheet.d.ts +3 -3
- package/react/dist/blocks/swap-sheet.js +3 -3
- package/react/dist/blocks/target-block.d.ts +7 -1
- package/react/dist/blocks/target-block.js +10 -4
- package/react/dist/blocks/token-action-block.d.ts +6 -2
- package/react/dist/blocks/token-action-block.js +3 -2
- package/react/dist/blocks/trade-history-detail-block.d.ts +3 -1
- package/react/dist/blocks/trade-history-detail-block.js +2 -2
- package/react/dist/blocks/trade-history-list-block.d.ts +3 -1
- package/react/dist/blocks/trade-history-list-block.js +7 -4
- package/react/dist/blocks.d.ts +8 -2
- package/react/dist/blocks.js +7 -1
- package/react/dist/brand.js +2 -1
- package/react/dist/button.d.ts +9 -3
- package/react/dist/button.js +8 -3
- package/react/dist/confetti.d.ts +27 -0
- package/react/dist/confetti.js +240 -0
- package/react/dist/data.js +8 -1
- package/react/dist/field.d.ts +6 -1
- package/react/dist/field.js +18 -9
- package/react/dist/gesture-sheet.d.ts +15 -1
- package/react/dist/gesture-sheet.js +53 -8
- package/react/dist/list-group.js +11 -7
- package/react/dist/navigation.js +11 -3
- package/react/dist/overlay.d.ts +1 -4
- package/react/dist/overlay.js +1 -3
- package/react/dist/popover.d.ts +30 -0
- package/react/dist/popover.js +34 -0
- package/react/dist/preset-group.d.ts +30 -0
- package/react/dist/preset-group.js +13 -0
- package/react/dist/provider.d.ts +2 -2
- package/react/dist/provider.js +23 -6
- 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 +13 -5
- package/react/dist/selection.js +13 -8
- 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 +260 -165
- package/react/dist/toast.d.ts +19 -12
- package/react/dist/toast.js +29 -7
- package/react/dist/wallet-address-core.d.ts +8 -4
- package/react/dist/wallet-address-core.js +10 -5
- package/tokens/README.md +2 -2
- package/tokens/assets/onramps/apple-pay.svg +33 -0
- package/tokens/assets/onramps/bank.svg +98 -0
- package/tokens/assets/onramps/blink.svg +37 -0
- package/tokens/assets/onramps/cashapp.svg +33 -0
- package/tokens/assets/onramps/crypto.svg +121 -0
- package/tokens/assets/onramps/exchange.svg +105 -0
- package/tokens/dist/deposit-icons.d.ts +1 -0
- package/tokens/dist/deposit-icons.js +28 -0
- 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
- package/react/dist/blocks/swap-panel-block.js +0 -178
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What every HIG toast host agrees on. On web Sonner is the engine and takes these values as props; on native HIG's own
|
|
3
|
+
* host runs the same arithmetic as worklets on the UI thread, so it is tested here as plain functions. The figures are
|
|
4
|
+
* Sonner's, read from sonner 2.0.8, except where a comment says otherwise.
|
|
5
|
+
*/
|
|
6
|
+
export type ToastSeverity = 'info' | 'success' | 'warning' | 'error';
|
|
7
|
+
export type ToastId = string | number;
|
|
8
|
+
export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
9
|
+
export type ToastSwipeDirection = 'top' | 'right' | 'bottom' | 'left';
|
|
10
|
+
/** Options `toast()` takes on every platform. Each platform adds `action`, a node of its own renderer. */
|
|
11
|
+
export interface ToastBaseOptions {
|
|
12
|
+
/** Picks the symbol and its token role. Where the platform can interrupt, an `error` is announced at once and everything else waits its turn. Default `info`. */
|
|
13
|
+
severity?: ToastSeverity;
|
|
14
|
+
/** A second line under the message, in regular weight. */
|
|
15
|
+
description?: string;
|
|
16
|
+
/** Accessible name of the close control; defaults to the provider's `dismissNotice` wording. */
|
|
17
|
+
dismissName?: string;
|
|
18
|
+
/** Milliseconds before the notice leaves by itself; the Toaster's `duration` when omitted. `Infinity` keeps it until dismissed. */
|
|
19
|
+
duration?: number;
|
|
20
|
+
/** Raising a notice with the id of one that is showing replaces it in place and restarts its time. */
|
|
21
|
+
id?: ToastId;
|
|
22
|
+
/** Called once when the notice is dismissed: its close control, a swipe, or `dismissToast`. */
|
|
23
|
+
onDismiss?: () => void;
|
|
24
|
+
/** Called once when the notice's time runs out. */
|
|
25
|
+
onAutoClose?: () => void;
|
|
26
|
+
}
|
|
27
|
+
/** `toast` as each platform exports it, with that platform's options: the call itself, a shorthand per severity, and `dismiss`, which is `dismissToast`. Each returns the notice's id. */
|
|
28
|
+
export interface ToastCall<Options> {
|
|
29
|
+
(message: string, options?: Options): ToastId;
|
|
30
|
+
success: (message: string, options?: Omit<Options, 'severity'>) => ToastId;
|
|
31
|
+
error: (message: string, options?: Omit<Options, 'severity'>) => ToastId;
|
|
32
|
+
warning: (message: string, options?: Omit<Options, 'severity'>) => ToastId;
|
|
33
|
+
info: (message: string, options?: Omit<Options, 'severity'>) => ToastId;
|
|
34
|
+
/** Dismisses one notice by id, or every notice when the id is omitted. */
|
|
35
|
+
dismiss: (id?: ToastId) => void;
|
|
36
|
+
}
|
|
37
|
+
/** Milliseconds a notice stays without a `duration`. */
|
|
38
|
+
export declare const TOAST_DURATION = 4000;
|
|
39
|
+
/** Notices drawn at once; older ones wait behind them. */
|
|
40
|
+
export declare const TOAST_VISIBLE = 3;
|
|
41
|
+
/** Points between notices in an expanded stack, and how far each one behind the front peeks out of a collapsed stack. */
|
|
42
|
+
export declare const TOAST_GAP = 14;
|
|
43
|
+
/** Width of the stack on a wide window, in points. A narrow window gives it the full width between the offsets. */
|
|
44
|
+
export declare const TOAST_WIDTH = 356;
|
|
45
|
+
/** Windows narrower than this are narrow. */
|
|
46
|
+
export declare const TOAST_NARROW = 600;
|
|
47
|
+
/** Distance from the screen edge on a wide and on a narrow window, added to the safe-area inset. */
|
|
48
|
+
export declare const TOAST_OFFSET = 24;
|
|
49
|
+
export declare const TOAST_NARROW_OFFSET = 16;
|
|
50
|
+
/** How much smaller each notice behind the front is drawn in a collapsed stack. */
|
|
51
|
+
export declare const TOAST_STACK_SCALE = 0.05;
|
|
52
|
+
/** Entering and restacking: 400ms on the CSS `ease` curve. */
|
|
53
|
+
export declare const TOAST_MOTION: {
|
|
54
|
+
readonly duration: 400;
|
|
55
|
+
readonly curve: readonly [0.25, 0.1, 0.25, 1];
|
|
56
|
+
};
|
|
57
|
+
/** Leaving, and the swipe out: 200ms on the CSS `ease-out` curve. */
|
|
58
|
+
export declare const TOAST_EXIT: {
|
|
59
|
+
readonly duration: 200;
|
|
60
|
+
readonly curve: readonly [0, 0, 0.58, 1];
|
|
61
|
+
};
|
|
62
|
+
/** Reduced motion: nothing slides or scales, and opacity changes over this long. HIG's own figure; Sonner cuts to the end state. */
|
|
63
|
+
export declare const TOAST_REDUCED_FADE = 150;
|
|
64
|
+
/** How long a finger rests on a notice before a collapsed stack expands under it, so a tap or a quick swipe does not stir the stack. HIG's own figure; on web the pointer hovering does this. */
|
|
65
|
+
export declare const TOAST_HOLD = 200;
|
|
66
|
+
/** A swipe released this far from rest dismisses. */
|
|
67
|
+
export declare const TOAST_SWIPE_THRESHOLD = 45;
|
|
68
|
+
/** A swipe released faster than this (points per second) dismisses whatever its distance. HIG's own figure: Sonner divides the distance by the time since the pointer went down, which a hold before the flick defeats. */
|
|
69
|
+
export declare const TOAST_FLICK = 500;
|
|
70
|
+
/** The longest time a platform timer counts: 2^31 - 1 milliseconds, about 24 days. A longer delay overflows and fires at once. */
|
|
71
|
+
export declare const TOAST_MAX_DURATION = 2147483647;
|
|
72
|
+
/**
|
|
73
|
+
* A `duration` as both hosts read it. Only a positive number is a time: anything else (omitted, zero, negative, `NaN`)
|
|
74
|
+
* is `undefined`, so the Toaster's `duration` applies, as Sonner treats it. A time no timer can count is `Infinity`, so
|
|
75
|
+
* the notice stays instead of leaving at once.
|
|
76
|
+
*/
|
|
77
|
+
export declare function toastDuration(duration: number | undefined): number | undefined;
|
|
78
|
+
/** Notices the store keeps; past it the oldest timed ones are dropped. HIG's own figure, bounding a burst. */
|
|
79
|
+
export declare const TOAST_QUEUE_LIMIT = 16;
|
|
80
|
+
/** The spring a released swipe returns on: critically damped, so it settles without a bounce. */
|
|
81
|
+
export declare const TOAST_SPRING: {
|
|
82
|
+
readonly damping: 36;
|
|
83
|
+
readonly stiffness: 320;
|
|
84
|
+
readonly mass: 1;
|
|
85
|
+
readonly overshootClamping: true;
|
|
86
|
+
};
|
|
87
|
+
/** The edge a position hangs from: `lift` is 1 when the stack grows down from the top and -1 when it grows up from the bottom. */
|
|
88
|
+
export declare function toastEdge(position: ToastPosition): {
|
|
89
|
+
y: 'top' | 'bottom';
|
|
90
|
+
x: 'left' | 'center' | 'right';
|
|
91
|
+
lift: 1 | -1;
|
|
92
|
+
};
|
|
93
|
+
/** Directions a swipe dismisses in when the host names none: towards the edges the stack sits against. */
|
|
94
|
+
export declare function toastSwipeDirections(position: ToastPosition): ToastSwipeDirection[];
|
|
95
|
+
/** One notice in the store. `key` never changes and is never reused; `revision` counts in-place replacements. */
|
|
96
|
+
export interface ToastEntry<T> {
|
|
97
|
+
key: number;
|
|
98
|
+
id: ToastId;
|
|
99
|
+
revision: number;
|
|
100
|
+
duration?: number;
|
|
101
|
+
leaving: boolean;
|
|
102
|
+
value: T;
|
|
103
|
+
}
|
|
104
|
+
/** Keeps at most `limit` live notices: the oldest timed ones go first, then the oldest of any kind, and the newest is the last to go. Notices already leaving are not counted. */
|
|
105
|
+
export declare function toastCap<T>(list: readonly ToastEntry<T>[], limit?: number): readonly ToastEntry<T>[];
|
|
106
|
+
/** Adds a notice as the newest, or replaces the live notice with the same id where it stands. A notice that is already leaving is not revived: the new one is added. */
|
|
107
|
+
export declare function toastUpsert<T>(list: readonly ToastEntry<T>[], next: {
|
|
108
|
+
key: number;
|
|
109
|
+
id: ToastId;
|
|
110
|
+
duration?: number;
|
|
111
|
+
value: T;
|
|
112
|
+
}, limit?: number): readonly ToastEntry<T>[];
|
|
113
|
+
/** Marks the live notice with this id, or every live notice when the id is omitted, as leaving. Returns the same list when nothing changed. */
|
|
114
|
+
export declare function toastLeave<T>(list: readonly ToastEntry<T>[], id?: ToastId): readonly ToastEntry<T>[];
|
|
115
|
+
/** Drops one notice for good, once it has left. Returns the same list when the key is gone already. */
|
|
116
|
+
export declare function toastRemove<T>(list: readonly ToastEntry<T>[], key: number): readonly ToastEntry<T>[];
|
|
117
|
+
/** The stack: live notices, newest (the front) first. */
|
|
118
|
+
export declare function toastOrder<T>(list: readonly ToastEntry<T>[]): ToastEntry<T>[];
|
|
119
|
+
/** Where a notice rests: a translation along the stack, its scale about its centre, its opacity and the opacity of what it holds. */
|
|
120
|
+
export interface ToastSlot {
|
|
121
|
+
y: number;
|
|
122
|
+
scaleX: number;
|
|
123
|
+
scaleY: number;
|
|
124
|
+
opacity: number;
|
|
125
|
+
content: number;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The resting place of the notice `index` places behind the front (0 is the front). `heights` are the laid-out heights of
|
|
129
|
+
* the stack, front first. Expanded, notices sit one after another `gap` apart. Collapsed, each notice behind the front is
|
|
130
|
+
* drawn at the front's height, a little smaller and `gap` further out, with its content hidden: only its far edge shows.
|
|
131
|
+
* Every notice is anchored at the stack's edge and scales about its own centre, so the translation carries the difference
|
|
132
|
+
* in height. A notice past `visible`, or not in the stack (`index` below 0), is transparent.
|
|
133
|
+
*/
|
|
134
|
+
export declare function toastSlot(index: number, heights: readonly number[], expanded: boolean, gap: number, visible: number, lift: 1 | -1): ToastSlot;
|
|
135
|
+
/** Where a notice starts its entrance: its own height before its slot, on the side the stack hangs from. */
|
|
136
|
+
export declare function toastEnterFrom(slotY: number, height: number, lift: 1 | -1): number;
|
|
137
|
+
/** Where a notice goes as it leaves: back out by its own height when it is the front or the stack is expanded, and nowhere (it fades where it is) from behind a collapsed stack. */
|
|
138
|
+
export declare function toastExitTo(slotY: number, height: number, lift: 1 | -1, slides: boolean): number;
|
|
139
|
+
/** The axis a drag is locked to, from its first movement. */
|
|
140
|
+
export declare function toastSwipeAxis(dx: number, dy: number): 'x' | 'y';
|
|
141
|
+
/**
|
|
142
|
+
* How far the notice follows a drag of `delta` points along its locked axis. `backward` allows the negative direction
|
|
143
|
+
* (left or up) and `forward` the positive one (right or down). An allowed direction follows the finger 1:1; the other
|
|
144
|
+
* resists more the further it goes and never passes 20 points. An axis with no allowed direction does not move.
|
|
145
|
+
*/
|
|
146
|
+
export declare function toastDrag(delta: number, backward: boolean, forward: boolean): number;
|
|
147
|
+
/** The drag distance that puts the notice where it already is, `amount` points from rest: `toastDrag` undone. A notice caught while it springs back carries on from there without a jump. */
|
|
148
|
+
export declare function toastGrab(amount: number, backward: boolean, forward: boolean): number;
|
|
149
|
+
/** Whether a release dismisses: in an allowed direction, and either far enough or fast enough that way. `velocity` is in points per second along the axis. */
|
|
150
|
+
export declare function toastSwipeDismisses(amount: number, velocity: number, backward: boolean, forward: boolean): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* The swipe out: on from where the finger let go by the notice's own `size` along the axis. It takes 200ms, or less for
|
|
153
|
+
* a fast flick so the notice does not slow down as it leaves the finger: the `ease-out` curve starts 1.72 times faster
|
|
154
|
+
* than its average speed, and the duration is chosen so that start matches the release velocity, no shorter than 100ms.
|
|
155
|
+
*/
|
|
156
|
+
export declare function toastSwipeOut(amount: number, velocity: number, size: number): {
|
|
157
|
+
to: number;
|
|
158
|
+
duration: number;
|
|
159
|
+
};
|
|
160
|
+
/** A notice's time: what is left, and when it last started running (`null` while paused). */
|
|
161
|
+
export interface ToastClock {
|
|
162
|
+
remaining: number;
|
|
163
|
+
startedAt: number | null;
|
|
164
|
+
}
|
|
165
|
+
/** Starts or keeps a clock running at `now`. */
|
|
166
|
+
export declare function toastClockRun(clock: ToastClock, now: number): ToastClock;
|
|
167
|
+
/** Pauses a clock at `now`, keeping what is left. */
|
|
168
|
+
export declare function toastClockPause(clock: ToastClock, now: number): ToastClock;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/** Milliseconds a notice stays without a `duration`. */
|
|
2
|
+
export const TOAST_DURATION = 4000;
|
|
3
|
+
/** Notices drawn at once; older ones wait behind them. */
|
|
4
|
+
export const TOAST_VISIBLE = 3;
|
|
5
|
+
/** Points between notices in an expanded stack, and how far each one behind the front peeks out of a collapsed stack. */
|
|
6
|
+
export const TOAST_GAP = 14;
|
|
7
|
+
/** Width of the stack on a wide window, in points. A narrow window gives it the full width between the offsets. */
|
|
8
|
+
export const TOAST_WIDTH = 356;
|
|
9
|
+
/** Windows narrower than this are narrow. */
|
|
10
|
+
export const TOAST_NARROW = 600;
|
|
11
|
+
/** Distance from the screen edge on a wide and on a narrow window, added to the safe-area inset. */
|
|
12
|
+
export const TOAST_OFFSET = 24;
|
|
13
|
+
export const TOAST_NARROW_OFFSET = 16;
|
|
14
|
+
/** How much smaller each notice behind the front is drawn in a collapsed stack. */
|
|
15
|
+
export const TOAST_STACK_SCALE = 0.05;
|
|
16
|
+
/** Entering and restacking: 400ms on the CSS `ease` curve. */
|
|
17
|
+
export const TOAST_MOTION = { duration: 400, curve: [0.25, 0.1, 0.25, 1] };
|
|
18
|
+
/** Leaving, and the swipe out: 200ms on the CSS `ease-out` curve. */
|
|
19
|
+
export const TOAST_EXIT = { duration: 200, curve: [0, 0, 0.58, 1] };
|
|
20
|
+
/** Reduced motion: nothing slides or scales, and opacity changes over this long. HIG's own figure; Sonner cuts to the end state. */
|
|
21
|
+
export const TOAST_REDUCED_FADE = 150;
|
|
22
|
+
/** How long a finger rests on a notice before a collapsed stack expands under it, so a tap or a quick swipe does not stir the stack. HIG's own figure; on web the pointer hovering does this. */
|
|
23
|
+
export const TOAST_HOLD = 200;
|
|
24
|
+
/** A swipe released this far from rest dismisses. */
|
|
25
|
+
export const TOAST_SWIPE_THRESHOLD = 45;
|
|
26
|
+
/** A swipe released faster than this (points per second) dismisses whatever its distance. HIG's own figure: Sonner divides the distance by the time since the pointer went down, which a hold before the flick defeats. */
|
|
27
|
+
export const TOAST_FLICK = 500;
|
|
28
|
+
/** The longest time a platform timer counts: 2^31 - 1 milliseconds, about 24 days. A longer delay overflows and fires at once. */
|
|
29
|
+
export const TOAST_MAX_DURATION = 2147483647;
|
|
30
|
+
/**
|
|
31
|
+
* A `duration` as both hosts read it. Only a positive number is a time: anything else (omitted, zero, negative, `NaN`)
|
|
32
|
+
* is `undefined`, so the Toaster's `duration` applies, as Sonner treats it. A time no timer can count is `Infinity`, so
|
|
33
|
+
* the notice stays instead of leaving at once.
|
|
34
|
+
*/
|
|
35
|
+
export function toastDuration(duration) {
|
|
36
|
+
if (duration === undefined || !(duration > 0))
|
|
37
|
+
return undefined;
|
|
38
|
+
return duration > TOAST_MAX_DURATION ? Infinity : duration;
|
|
39
|
+
}
|
|
40
|
+
/** Notices the store keeps; past it the oldest timed ones are dropped. HIG's own figure, bounding a burst. */
|
|
41
|
+
export const TOAST_QUEUE_LIMIT = 16;
|
|
42
|
+
/** The spring a released swipe returns on: critically damped, so it settles without a bounce. */
|
|
43
|
+
export const TOAST_SPRING = { damping: 36, stiffness: 320, mass: 1, overshootClamping: true };
|
|
44
|
+
/** The edge a position hangs from: `lift` is 1 when the stack grows down from the top and -1 when it grows up from the bottom. */
|
|
45
|
+
export function toastEdge(position) {
|
|
46
|
+
const [y, x] = position.split('-');
|
|
47
|
+
return { y, x, lift: y === 'top' ? 1 : -1 };
|
|
48
|
+
}
|
|
49
|
+
/** Directions a swipe dismisses in when the host names none: towards the edges the stack sits against. */
|
|
50
|
+
export function toastSwipeDirections(position) {
|
|
51
|
+
const { y, x } = toastEdge(position);
|
|
52
|
+
return x === 'center' ? [y] : [y, x];
|
|
53
|
+
}
|
|
54
|
+
const persistent = (entry) => entry.duration === Infinity;
|
|
55
|
+
/** Keeps at most `limit` live notices: the oldest timed ones go first, then the oldest of any kind, and the newest is the last to go. Notices already leaving are not counted. */
|
|
56
|
+
export function toastCap(list, limit = TOAST_QUEUE_LIMIT) {
|
|
57
|
+
let overflow = list.filter(entry => !entry.leaving).length - limit;
|
|
58
|
+
if (overflow <= 0)
|
|
59
|
+
return list;
|
|
60
|
+
const newest = list.length - 1;
|
|
61
|
+
let kept = list.filter((entry, index) => { if (overflow <= 0 || index === newest || entry.leaving || persistent(entry))
|
|
62
|
+
return true; overflow -= 1; return false; });
|
|
63
|
+
if (overflow > 0)
|
|
64
|
+
kept = kept.filter(entry => { if (overflow <= 0 || entry.leaving)
|
|
65
|
+
return true; overflow -= 1; return false; });
|
|
66
|
+
return kept;
|
|
67
|
+
}
|
|
68
|
+
/** Adds a notice as the newest, or replaces the live notice with the same id where it stands. A notice that is already leaving is not revived: the new one is added. */
|
|
69
|
+
export function toastUpsert(list, next, limit = TOAST_QUEUE_LIMIT) {
|
|
70
|
+
const index = list.findIndex(entry => entry.id === next.id && !entry.leaving);
|
|
71
|
+
if (index < 0)
|
|
72
|
+
return toastCap([...list, { ...next, revision: 0, leaving: false }], limit);
|
|
73
|
+
const copy = list.slice();
|
|
74
|
+
copy[index] = { ...list[index], duration: next.duration, value: next.value, revision: list[index].revision + 1 };
|
|
75
|
+
return copy;
|
|
76
|
+
}
|
|
77
|
+
/** Marks the live notice with this id, or every live notice when the id is omitted, as leaving. Returns the same list when nothing changed. */
|
|
78
|
+
export function toastLeave(list, id) {
|
|
79
|
+
if (!list.some(entry => !entry.leaving && (id === undefined || entry.id === id)))
|
|
80
|
+
return list;
|
|
81
|
+
return list.map(entry => !entry.leaving && (id === undefined || entry.id === id) ? { ...entry, leaving: true } : entry);
|
|
82
|
+
}
|
|
83
|
+
/** Drops one notice for good, once it has left. Returns the same list when the key is gone already. */
|
|
84
|
+
export function toastRemove(list, key) {
|
|
85
|
+
return list.some(entry => entry.key === key) ? list.filter(entry => entry.key !== key) : list;
|
|
86
|
+
}
|
|
87
|
+
/** The stack: live notices, newest (the front) first. */
|
|
88
|
+
export function toastOrder(list) {
|
|
89
|
+
return list.filter(entry => !entry.leaving).reverse();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The resting place of the notice `index` places behind the front (0 is the front). `heights` are the laid-out heights of
|
|
93
|
+
* the stack, front first. Expanded, notices sit one after another `gap` apart. Collapsed, each notice behind the front is
|
|
94
|
+
* drawn at the front's height, a little smaller and `gap` further out, with its content hidden: only its far edge shows.
|
|
95
|
+
* Every notice is anchored at the stack's edge and scales about its own centre, so the translation carries the difference
|
|
96
|
+
* in height. A notice past `visible`, or not in the stack (`index` below 0), is transparent.
|
|
97
|
+
*/
|
|
98
|
+
export function toastSlot(index, heights, expanded, gap, visible, lift) {
|
|
99
|
+
'worklet';
|
|
100
|
+
const opacity = index >= 0 && index < visible ? 1 : 0;
|
|
101
|
+
if (index <= 0)
|
|
102
|
+
return { y: 0, scaleX: 1, scaleY: 1, opacity, content: 1 };
|
|
103
|
+
if (expanded) {
|
|
104
|
+
let before = 0;
|
|
105
|
+
for (let place = 0; place < index; place++)
|
|
106
|
+
before += heights[place] ?? 0;
|
|
107
|
+
return { y: lift * (before + index * gap), scaleX: 1, scaleY: 1, opacity, content: 1 };
|
|
108
|
+
}
|
|
109
|
+
const front = heights[0] ?? 0, own = heights[index] ?? 0, scale = Math.max(0, 1 - index * TOAST_STACK_SCALE);
|
|
110
|
+
return { y: lift * (index * gap + (front - own) / 2), scaleX: scale, scaleY: own > 0 && front > 0 ? scale * front / own : scale, opacity, content: 0 };
|
|
111
|
+
}
|
|
112
|
+
/** Where a notice starts its entrance: its own height before its slot, on the side the stack hangs from. */
|
|
113
|
+
export function toastEnterFrom(slotY, height, lift) {
|
|
114
|
+
'worklet';
|
|
115
|
+
return slotY - lift * height;
|
|
116
|
+
}
|
|
117
|
+
/** Where a notice goes as it leaves: back out by its own height when it is the front or the stack is expanded, and nowhere (it fades where it is) from behind a collapsed stack. */
|
|
118
|
+
export function toastExitTo(slotY, height, lift, slides) {
|
|
119
|
+
'worklet';
|
|
120
|
+
return slides ? slotY - lift * height : slotY;
|
|
121
|
+
}
|
|
122
|
+
/** The axis a drag is locked to, from its first movement. */
|
|
123
|
+
export function toastSwipeAxis(dx, dy) {
|
|
124
|
+
'worklet';
|
|
125
|
+
return Math.abs(dx) > Math.abs(dy) ? 'x' : 'y';
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* How far the notice follows a drag of `delta` points along its locked axis. `backward` allows the negative direction
|
|
129
|
+
* (left or up) and `forward` the positive one (right or down). An allowed direction follows the finger 1:1; the other
|
|
130
|
+
* resists more the further it goes and never passes 20 points. An axis with no allowed direction does not move.
|
|
131
|
+
*/
|
|
132
|
+
export function toastDrag(delta, backward, forward) {
|
|
133
|
+
'worklet';
|
|
134
|
+
if (!backward && !forward)
|
|
135
|
+
return 0;
|
|
136
|
+
if (delta < 0 ? backward : forward)
|
|
137
|
+
return delta;
|
|
138
|
+
return delta / (1.5 + Math.abs(delta) / 20);
|
|
139
|
+
}
|
|
140
|
+
/** The drag distance that puts the notice where it already is, `amount` points from rest: `toastDrag` undone. A notice caught while it springs back carries on from there without a jump. */
|
|
141
|
+
export function toastGrab(amount, backward, forward) {
|
|
142
|
+
'worklet';
|
|
143
|
+
if (!backward && !forward)
|
|
144
|
+
return 0;
|
|
145
|
+
if (amount < 0 ? backward : forward)
|
|
146
|
+
return amount;
|
|
147
|
+
const size = Math.min(Math.abs(amount), 19.9);
|
|
148
|
+
return (amount < 0 ? -1 : 1) * 1.5 * size / (1 - size / 20);
|
|
149
|
+
}
|
|
150
|
+
/** Whether a release dismisses: in an allowed direction, and either far enough or fast enough that way. `velocity` is in points per second along the axis. */
|
|
151
|
+
export function toastSwipeDismisses(amount, velocity, backward, forward) {
|
|
152
|
+
'worklet';
|
|
153
|
+
if (amount === 0 || !(amount < 0 ? backward : forward))
|
|
154
|
+
return false;
|
|
155
|
+
return Math.abs(amount) >= TOAST_SWIPE_THRESHOLD || velocity * (amount < 0 ? -1 : 1) >= TOAST_FLICK;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The swipe out: on from where the finger let go by the notice's own `size` along the axis. It takes 200ms, or less for
|
|
159
|
+
* a fast flick so the notice does not slow down as it leaves the finger: the `ease-out` curve starts 1.72 times faster
|
|
160
|
+
* than its average speed, and the duration is chosen so that start matches the release velocity, no shorter than 100ms.
|
|
161
|
+
*/
|
|
162
|
+
export function toastSwipeOut(amount, velocity, size) {
|
|
163
|
+
'worklet';
|
|
164
|
+
const direction = amount < 0 ? -1 : 1, speed = velocity * direction;
|
|
165
|
+
const matched = speed > 0 ? 1.72 * size / speed * 1000 : TOAST_EXIT.duration;
|
|
166
|
+
return { to: amount + direction * size, duration: Math.max(100, Math.min(TOAST_EXIT.duration, matched)) };
|
|
167
|
+
}
|
|
168
|
+
/** Starts or keeps a clock running at `now`. */
|
|
169
|
+
export function toastClockRun(clock, now) { return clock.startedAt === null ? { remaining: clock.remaining, startedAt: now } : clock; }
|
|
170
|
+
/** Pauses a clock at `now`, keeping what is left. */
|
|
171
|
+
export function toastClockPause(clock, now) { return clock.startedAt === null ? clock : { remaining: Math.max(0, clock.remaining - (now - clock.startedAt)), startedAt: null }; }
|
package/feedback/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bloxwap/hig/feedback
|
|
2
2
|
|
|
3
|
-
Version 0.
|
|
3
|
+
Version 0.9.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
|
|
|
@@ -37,7 +37,7 @@ export class FeedbackController {
|
|
|
37
37
|
attempt(this.options.haptics?.cancel?.bind(this.options.haptics));
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
const now = this.clock(), key =
|
|
40
|
+
const now = this.clock(), key = JSON.stringify([event.source, event.id, event.intent]), cadenceKey = JSON.stringify([event.source, event.intent]);
|
|
41
41
|
if (this.seen.has(key) || now - (this.cadence.get(cadenceKey) ?? -Infinity) < presets[event.intent].cooldown)
|
|
42
42
|
return;
|
|
43
43
|
this.seen.set(key, now);
|
package/feedback/dist/react.js
CHANGED
|
@@ -9,13 +9,11 @@ export function FeedbackProvider({ children, createController, storage, initialP
|
|
|
9
9
|
const current = useRef(preferences);
|
|
10
10
|
const revision = useRef(0);
|
|
11
11
|
const controller = useRef(null);
|
|
12
|
+
const writes = useRef(Promise.resolve());
|
|
12
13
|
const [sink] = useState(() => ({ emit: event => controller.current?.emit(event) }));
|
|
13
14
|
useEffect(() => { const instance = createController(current.current); controller.current = instance; let alive = true; void loadPreferences(storage, () => revision.current, value => { if (!alive)
|
|
14
15
|
return; current.current = value; setPreferences(value); instance.updatePreferences(value); }); return () => { alive = false; controller.current = null; instance.dispose(); }; }, [createController, storage]);
|
|
15
|
-
const update = useCallback((next) => { revision.current++; const value = migratePreferences({ ...current.current, ...next }); current.current = value; setPreferences(value); controller.current?.updatePreferences(value);
|
|
16
|
-
Promise.resolve(storage?.write(value)).catch(() => { });
|
|
17
|
-
}
|
|
18
|
-
catch { /* Preferences remain live without storage. */ } }, [storage]);
|
|
16
|
+
const update = useCallback((next) => { revision.current++; const value = migratePreferences({ ...current.current, ...next }); current.current = value; setPreferences(value); controller.current?.updatePreferences(value); writes.current = writes.current.then(() => storage?.write(value)).then(() => { }, () => { }); }, [storage]);
|
|
19
17
|
const getController = useCallback(() => controller.current, []);
|
|
20
18
|
return _jsx(Context.Provider, { value: { preferences, update, sink, controller: getController }, children: children });
|
|
21
19
|
}
|
package/native/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# @bloxwap/hig/native
|
|
2
2
|
|
|
3
|
-
Version 0.
|
|
3
|
+
Version 0.9.0, an entry of `@bloxwap/hig`. Import individual entries; see docs/components for platform and accessibility contracts.
|
|
4
|
+
|
|
5
|
+
UI symbols come from `@bloxwap/icons` (install `@bloxwap/icons@^0.1.0`). Native symbols also require the `expo-image` version for your Expo SDK.
|
|
6
|
+
Use `npx expo install expo-image`, then rebuild a development client so the native
|
|
7
|
+
module is linked. The adapter uses one image view with a local SVG source and
|
|
8
|
+
native tint; iOS renders the tinted image at the view size.
|
|
4
9
|
|
|
5
10
|
Set a brand accent with `<HIGProvider primaryColor='#ff0000'>` from
|
|
6
11
|
`@bloxwap/hig/native/provider`. It accepts opaque sRGB hex (`#RGB` or `#RRGGBB`),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type ScrollViewProps } from 'react-native';
|
|
2
3
|
import { type AssetArtwork } from './asset-balance-row.js';
|
|
3
4
|
export { AssetBalanceRow, type AssetArtwork, type AssetBalanceRowProps } from './asset-balance-row.js';
|
|
4
5
|
/** One holding in the account. The host supplies every value; HIG sorts, formats and lays it out. */
|
|
@@ -72,6 +73,14 @@ export interface AccountBlockProps {
|
|
|
72
73
|
depositLabel?: string;
|
|
73
74
|
/** Makes each row a button that reports its asset, and with `sections` the section it is in. */
|
|
74
75
|
onAssetSelect?: (asset: AccountAsset, section?: AccountSection) => void;
|
|
76
|
+
/** Keeps the header pinned while the rest scrolls: the block becomes its own scroll view with the header as its sticky first child, transparent at rest and filled once content scrolls under it. Place it in a bounded container, such as a sheet body. */
|
|
77
|
+
stickyHeader?: boolean;
|
|
78
|
+
/** With `stickyHeader`: the header's fill once content is under it. Defaults to the background role; in a sheet pass the sheet's fill. */
|
|
79
|
+
stickyHeaderBackground?: string;
|
|
80
|
+
/** The scroll view used with `stickyHeader`, such as a sheet library's own. Defaults to React Native's ScrollView. */
|
|
81
|
+
scrollComponent?: React.ComponentType<ScrollViewProps>;
|
|
82
|
+
/** `nativeID` of the title, so a sheet around the block can name itself with `accessibilityLabelledBy` (Android). */
|
|
83
|
+
headingId?: string;
|
|
75
84
|
testID?: string;
|
|
76
85
|
}
|
|
77
86
|
/** An asset's dollar value: its own `value`, else balance × price, else unknown. */
|
|
@@ -89,4 +98,4 @@ export declare function accountSectionRows(assets: readonly AccountAsset[], pinn
|
|
|
89
98
|
rest: AccountAsset[];
|
|
90
99
|
};
|
|
91
100
|
/** 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;
|
|
101
|
+
export declare function AccountBlock({ title, onBack, onShowAddress, headerAction, balance, assets, sections, pinnedSymbol, pinnedId, order, onDeposit, depositLabel, onAssetSelect, stickyHeader, stickyHeaderBackground, scrollComponent, headingId, testID }: AccountBlockProps): React.JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
+
import { StickyHeaderLayout } from './sticky-header.js';
|
|
3
4
|
import { useColors, useHIG, useMessages } from './provider.js';
|
|
4
5
|
import { Text } from './surface.js';
|
|
5
6
|
import { Button, IconButton } from './button.js';
|
|
@@ -10,7 +11,7 @@ export { AssetBalanceRow } from './asset-balance-row.js';
|
|
|
10
11
|
const usdc = 'USDC', usdCoin = 'USD Coin';
|
|
11
12
|
const usd = { style: 'currency', currency: 'USD' };
|
|
12
13
|
/** 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
|
+
export const assetValue = (asset) => { const value = asset.value !== undefined ? asset.value : asset.balance != null && asset.price != null ? asset.balance * asset.price : null; return value != null && Number.isFinite(value) ? value : null; };
|
|
14
15
|
/** 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
16
|
export function accountRows(assets, pinnedSymbol = usdc, options = {}) {
|
|
16
17
|
const wanted = pinnedSymbol.toLowerCase();
|
|
@@ -20,23 +21,28 @@ export function accountRows(assets, pinnedSymbol = usdc, options = {}) {
|
|
|
20
21
|
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
22
|
return { pinned, rest };
|
|
22
23
|
}
|
|
23
|
-
const sum = (assets) =>
|
|
24
|
+
const sum = (assets) => { let total = 0; for (const asset of assets) {
|
|
25
|
+
const value = assetValue(asset);
|
|
26
|
+
if (value == null || !Number.isFinite(value))
|
|
27
|
+
return null;
|
|
28
|
+
total += value;
|
|
29
|
+
} return Number.isFinite(total) ? total : null; };
|
|
24
30
|
/** 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);
|
|
31
|
+
export const accountSectionTotal = (section) => section.total !== undefined ? (section.total != null && Number.isFinite(section.total) ? section.total : null) : sum(section.assets);
|
|
26
32
|
/** 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
33
|
const accountSectionsTotal = (sections) => { let all = 0; for (const section of sections) {
|
|
28
34
|
const total = accountSectionTotal(section);
|
|
29
35
|
if (total === null)
|
|
30
36
|
return null;
|
|
31
37
|
all += total;
|
|
32
|
-
} return all; };
|
|
38
|
+
} return Number.isFinite(all) ? all : null; };
|
|
33
39
|
/** 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
40
|
export function accountSectionRows(assets, pinnedSymbol = usdc, options = {}) {
|
|
35
41
|
const { pinned, rest } = accountRows(assets, pinnedSymbol, options);
|
|
36
42
|
return { pinned: assets.includes(pinned) ? pinned : null, rest };
|
|
37
43
|
}
|
|
38
44
|
/** 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 }) {
|
|
45
|
+
export function AccountBlock({ title, onBack, onShowAddress, headerAction, balance, assets = [], sections, pinnedSymbol = usdc, pinnedId, order, onDeposit, depositLabel, onAssetSelect, stickyHeader, stickyHeaderBackground, scrollComponent, headingId, testID }) {
|
|
40
46
|
const colors = useColors(), t = useMessages(), { direction } = useHIG();
|
|
41
47
|
const shown = sections?.filter(section => section.assets.length > 0);
|
|
42
48
|
const total = balance !== undefined ? balance : shown ? accountSectionsTotal(shown) : sum(assets);
|
|
@@ -57,5 +63,9 @@ export function AccountBlock({ title, onBack, onShowAddress, headerAction, balan
|
|
|
57
63
|
const { pinned, rest } = accountRows(assets, pinnedSymbol, { order, pinnedId });
|
|
58
64
|
list = _jsxs(View, { testID: 'account-assets', style: { gap: 8, marginTop: 16 }, children: [row(pinned, true, pinnedId), rest.map(asset => row(asset, false, pinnedId))] });
|
|
59
65
|
}
|
|
60
|
-
|
|
66
|
+
const header = _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', nativeID: headingId, 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) })] });
|
|
67
|
+
const body = _jsxs(_Fragment, { children: [_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] });
|
|
68
|
+
if (stickyHeader)
|
|
69
|
+
return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: 'account-sticky-header', header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: body });
|
|
70
|
+
return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [header, body] });
|
|
61
71
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NumberFlowPlace } from '@bloxwap/hig/contracts/number-flow';
|
|
1
2
|
export type NumberTrend = -1 | 0 | 1 | ((previousValue: number, value: number) => -1 | 0 | 1);
|
|
2
3
|
export interface NumberReading {
|
|
3
4
|
known: boolean;
|
|
@@ -27,4 +28,43 @@ export declare function safeNumberLayout(text: string, direction: string): boole
|
|
|
27
28
|
* numbers itself, for example because the runtime's Intl does not match its number table.
|
|
28
29
|
*/
|
|
29
30
|
export declare function createFormattedReelModel(text: string, locale: string, direction: string): NumberReelModel | null;
|
|
30
|
-
|
|
31
|
+
/** The reels of a reading, or `null` where it is drawn static. `reading` is the readout's own text for the value (`formatNumberReadout(...).core`) when the caller already has it, so it is not formatted twice. */
|
|
32
|
+
export declare function createNumberReelModel(value: number | null | undefined, locale: string, options: Intl.NumberFormatOptions | undefined, formattedValue: string | undefined, direction: string, animateFormatted?: boolean, reading?: string): NumberReelModel | null;
|
|
33
|
+
/** The NumberFlow place of a reel: an integer reel's own place (0 is the ones), a negative one for a fraction reel (-1 is the tenths), `null` for an exponent's. */
|
|
34
|
+
export declare function numberReelPlace(token: Pick<NumberReelToken, 'type' | 'place'>): number | null;
|
|
35
|
+
/** The reels of a model as NumberFlow places, in display order. */
|
|
36
|
+
export declare function numberReelPlaces(model: NumberReelModel): NumberFlowPlace[];
|
|
37
|
+
/**
|
|
38
|
+
* Where a reel's strip sits for a position that has turned any number of times either way. The strip is `length + 1` glyphs,
|
|
39
|
+
* the last repeating the first, so every position between two digits (9 to 0 included) is two neighbouring rows. UI thread.
|
|
40
|
+
*/
|
|
41
|
+
export declare function numberFlowReelOffset(position: number, length: number, height: number): number;
|
|
42
|
+
/** Progress along a sampled curve (first sample 0, last 1) at time `progress`. The UI-thread twin of `sampleNumberFlowEasing`. */
|
|
43
|
+
export declare function sampleReelEasing(samples: readonly number[], progress: number): number;
|
|
44
|
+
export type NumberFlowTurn = {
|
|
45
|
+
delta: number;
|
|
46
|
+
start: number;
|
|
47
|
+
duration: number;
|
|
48
|
+
};
|
|
49
|
+
/** A Reanimated animation object: one reel position, which is its target less what every turn still in flight has left to go. */
|
|
50
|
+
export type NumberFlowRoll = {
|
|
51
|
+
type: 'hig-number-flow';
|
|
52
|
+
current: number;
|
|
53
|
+
toValue: number;
|
|
54
|
+
turns: NumberFlowTurn[];
|
|
55
|
+
reduceMotion: false;
|
|
56
|
+
onStart: (animation: NumberFlowRoll, value: number, now: number, previous?: {
|
|
57
|
+
type?: string;
|
|
58
|
+
toValue?: unknown;
|
|
59
|
+
turns?: NumberFlowTurn[];
|
|
60
|
+
} | null) => void;
|
|
61
|
+
onFrame: (animation: NumberFlowRoll, now: number) => boolean;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* One turn of a reel by `delta` glyphs, for `defineAnimation`. A new turn does not restart the reel: it is added to the turns
|
|
65
|
+
* still in flight, each keeping its own clock and curve, which is what NumberFlow's additive animations do on web. So a reel
|
|
66
|
+
* asked to move again while it moves keeps its speed instead of easing in from rest every time, and it always ends on the
|
|
67
|
+
* digit the last turn asked for. With nothing in flight `onFrame` reports finished and the frame callback stops. HIG's
|
|
68
|
+
* provider decides reduced motion, so the system setting is not consulted here. UI thread.
|
|
69
|
+
*/
|
|
70
|
+
export declare function createNumberFlowRoll(delta: number, duration: number, samples: readonly number[]): NumberFlowRoll;
|