solid-drift 0.7.1 → 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/dist/web3.d.ts ADDED
@@ -0,0 +1,213 @@
1
+ /**
2
+ * web3 family: motion primitives for onchain product UI.
3
+ *
4
+ * Transaction lifecycle, price tickers, mint reveals, and wallet
5
+ * button micro-interactions, without depending on any wallet or chain
6
+ * library. State arrives through accessors in a wagmi/viem-style
7
+ * shape (the adapter pattern), so the primitives stay zero-dependency
8
+ * while your app keeps its own stack.
9
+ *
10
+ * All primitives are signal-native, SSR-safe, dependency-free, and
11
+ * define sensible static behavior under `prefers-reduced-motion`.
12
+ */
13
+ import { type Accessor } from "solid-js";
14
+ import { type Easing, type EasingName } from "./easing.js";
15
+ type MaybeElement = () => Element | null | undefined;
16
+ /** Stages of a transaction's life, from wallet prompt to finality. */
17
+ export type TxState = "idle" | "signing" | "pending" | "confirming" | "success" | "failed";
18
+ /** wagmi/viem-style transaction status fed through `source`. */
19
+ export interface TxStatusInput {
20
+ /** Transaction status from the wallet/chain adapter. */
21
+ status?: "pending" | "success" | "error" | "idle";
22
+ /** Confirmations seen so far, once a hash exists. */
23
+ confirmations?: number;
24
+ }
25
+ export interface TxLifecycleOptions {
26
+ /**
27
+ * wagmi/viem-style state accessor. Omit for fully manual control
28
+ * through `set()`.
29
+ */
30
+ source?: Accessor<TxStatusInput>;
31
+ /** Confirmations that promote "pending" to "confirming". Default 1. */
32
+ requiredConfirmations?: number;
33
+ /** Spring stiffness for the progress ring. Default 170. */
34
+ stiffness?: number;
35
+ /** Spring damping for the progress ring. Default 26. */
36
+ damping?: number;
37
+ /** Called after entering a state, with the previous state. */
38
+ onEnter?: (state: TxState, prev: TxState) => void;
39
+ }
40
+ export interface TxLifecycleControls {
41
+ /** Current lifecycle state. */
42
+ state: Accessor<TxState>;
43
+ /**
44
+ * Set the state manually, for stages the chain never reports
45
+ * (for example "signing" when the wallet prompt opens).
46
+ */
47
+ set: (next: TxState) => void;
48
+ /** Return to "idle". */
49
+ reset: () => void;
50
+ /**
51
+ * 0 to 1 across the lifecycle, spring-smoothed for progress rings
52
+ * and bars: idle 0, signing 0.25, pending 0.5, confirming 0.75,
53
+ * success/failed 1.
54
+ */
55
+ progress: Accessor<number>;
56
+ }
57
+ /**
58
+ * Signal-native transaction lifecycle.
59
+ *
60
+ * Feed it wagmi/viem-style state through `source` and it derives the
61
+ * stage: a reported hash with too few confirmations is "pending",
62
+ * enough confirmations is "confirming", success/error map to
63
+ * "success"/"failed". Stages the chain never reports, like "signing"
64
+ * while the wallet prompt is open, are set manually.
65
+ *
66
+ * ```ts
67
+ * const tx = createTxLifecycle({
68
+ * source: () => ({
69
+ * status: receiptQuery.status, // "pending" | "success" | "error" | "idle"
70
+ * confirmations: receiptQuery.confirmations,
71
+ * }),
72
+ * requiredConfirmations: 2,
73
+ * })
74
+ * const openWallet = () => {
75
+ * tx.set("signing")
76
+ * sendTransaction()
77
+ * }
78
+ * // <ProgressRing value={tx.progress()} state={tx.state()} />
79
+ * ```
80
+ *
81
+ * SSR-safe: "idle" with `progress()` 0. Under reduced motion state
82
+ * changes apply instantly and `progress()` jumps to its target.
83
+ */
84
+ export declare function createTxLifecycle(options?: TxLifecycleOptions): TxLifecycleControls;
85
+ export interface TickerOptions {
86
+ /** Decimals in the formatted output. Default 2. */
87
+ decimals?: number;
88
+ /** Roll duration per digit, in ms. Default 400. */
89
+ duration?: number;
90
+ /** Flash color when the value rises. Default "#16a34a". */
91
+ upColor?: string;
92
+ /** Flash color when the value falls. Default "#dc2626". */
93
+ downColor?: string;
94
+ /** How long the flash color holds, in ms. Default 600. */
95
+ flashMs?: number;
96
+ /** Locale for grouping separators. Default "en-US". */
97
+ locale?: string;
98
+ }
99
+ export interface TickerControls {
100
+ /** Formatted value, SSR-safe. */
101
+ display: Accessor<string>;
102
+ /** Direction of the last update: "up" | "down" | "flat". */
103
+ direction: Accessor<"up" | "down" | "flat">;
104
+ }
105
+ /**
106
+ * Animated price/balance ticker: per-digit roll, direction flash.
107
+ *
108
+ * Each digit is a 0-9 strip in an overflow-hidden column, driven by a
109
+ * single rAF task for the whole ticker. Rapid source updates batch to
110
+ * one render per frame, keeping only the latest value, so a hot price
111
+ * feed never queues animation debt. Non-digit characters (decimal
112
+ * point, grouping separators, minus sign) render statically.
113
+ *
114
+ * ```tsx
115
+ * let el!: HTMLSpanElement
116
+ * const [price, setPrice] = createSignal(48210.5)
117
+ * const ticker = createTicker(price, () => el, { decimals: 2 })
118
+ * <span ref={el} style={{ color: ticker.direction() === "up" ? "green" : "red" }}>
119
+ * {ticker.display()}
120
+ * </span>
121
+ * ```
122
+ *
123
+ * SSR-safe: `display()` returns the formatted string with no DOM.
124
+ * Under reduced motion the text swaps instantly: no roll, no flash.
125
+ */
126
+ export declare function createTicker(source: Accessor<number>, ref: MaybeElement, options?: TickerOptions): TickerControls;
127
+ export type MintRevealStatus = "idle" | "anticipating" | "flipping" | "revealed";
128
+ export interface MintRevealOptions {
129
+ /** Anticipation shake duration, in ms. Default 500. */
130
+ shakeDuration?: number;
131
+ /** rotateY flip duration, in ms. Default 700. */
132
+ flipDuration?: number;
133
+ /** Squash and stretch on landing. Default true. */
134
+ squash?: boolean;
135
+ /** Easing for the flip. Default "easeOutCubic". */
136
+ easing?: Easing | EasingName;
137
+ /** Called at the flip midpoint: swap the card faces here. */
138
+ onFlip?: () => void;
139
+ }
140
+ export interface MintRevealControls {
141
+ /** Play the full reveal choreography. Resolves when revealed. */
142
+ play: () => Promise<void>;
143
+ /** Return to "idle". */
144
+ reset: () => void;
145
+ /** Reactive status. */
146
+ status: Accessor<MintRevealStatus>;
147
+ }
148
+ /**
149
+ * Pack-open / card-reveal choreography, built on the cartoon family:
150
+ * an anticipation shake, a rotateY flip with a face swap at the
151
+ * midpoint, and squash and stretch driven by the flip's own velocity
152
+ * as the card lands. Everything stays on compositor-friendly
153
+ * properties (transform, and the CSS `scale` property for the deform).
154
+ *
155
+ * ```tsx
156
+ * let card!: HTMLDivElement
157
+ * const [face, setFace] = createSignal<"back" | "front">("back")
158
+ * const reveal = createMintReveal(() => card, {
159
+ * onFlip: () => setFace("front"), // swap faces mid-flip
160
+ * })
161
+ * <button onClick={() => reveal.play()}>Reveal</button>
162
+ * <div ref={card} style={{ "backface-visibility": "hidden" }}>
163
+ * {face() === "back" ? <CardBack /> : <NftFront />}
164
+ * </div>
165
+ * ```
166
+ *
167
+ * SSR-safe: no-op on the server, `status()` is "revealed" so the face
168
+ * renders statically. Under reduced motion the shake and flip are
169
+ * skipped and the final face shows at once.
170
+ */
171
+ export declare function createMintReveal(ref: MaybeElement, options?: MintRevealOptions): MintRevealControls;
172
+ export interface ConnectButtonOptions {
173
+ /** Magnetic pull strength, 0 to 1. Default 0.35. */
174
+ strength?: number;
175
+ /** Scale while pressed. Default 0.96. */
176
+ pressScale?: number;
177
+ }
178
+ export type ConnectButtonStatus = "idle" | "ticking" | "pulsing";
179
+ export interface ConnectButtonControls {
180
+ /** Checkmark tick for copy-address feedback. */
181
+ copyTick: () => void;
182
+ /** Expanding ring pulse for chain switches. */
183
+ chainPulse: () => void;
184
+ /** Reactive status: "idle" | "ticking" | "pulsing". */
185
+ status: Accessor<ConnectButtonStatus>;
186
+ }
187
+ /**
188
+ * Wallet connect-button micro-interactions: magnetic hover pull,
189
+ * press scale, a checkmark tick for copy-address feedback, and an
190
+ * expanding ring pulse for chain switches.
191
+ *
192
+ * The button's transform is owned by the primitive (magnetic pull
193
+ * plus press scale); the tick and pulse animate overlay spans so
194
+ * they never fight the hover motion. The button is given
195
+ * `position: relative` the first time a tick or pulse runs, to stage
196
+ * the overlays.
197
+ *
198
+ * ```tsx
199
+ * let btn!: HTMLButtonElement
200
+ * const connect = createConnectButton(() => btn)
201
+ * const copy = async () => {
202
+ * await navigator.clipboard.writeText(address())
203
+ * connect.copyTick()
204
+ * }
205
+ * <button ref={btn} onClick={copy}>0x7a…f3c2</button>
206
+ * ```
207
+ *
208
+ * SSR-safe: no-op on the server. Under reduced motion the magnetic
209
+ * pull is off and the tick/pulse become instant state changes (the
210
+ * check shows statically, then hides).
211
+ */
212
+ export declare function createConnectButton(ref: MaybeElement, options?: ConnectButtonOptions): ConnectButtonControls;
213
+ export {};