@bufinance/web3-signin 0.1.2 → 0.1.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bufinance/web3-signin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Headless cross-app Web3 wallet sign-in for BUFI: EIP-6963 wallet discovery + Supabase signInWithWeb3 (EIP-4361) + Turnstile captcha. Shared by desk-v1 and defi-web-app. Source of truth lives here; both apps consume it.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -32,6 +32,19 @@ export interface WalletDropdownProps {
|
|
|
32
32
|
scope?: WalletScope | "all";
|
|
33
33
|
/** Currency formatter for the USD total; defaults to en-US $. */
|
|
34
34
|
formatUsd?: (n: number) => string;
|
|
35
|
+
/**
|
|
36
|
+
* Custom trigger (pill) renderer. When provided, replaces the built-in
|
|
37
|
+
* text-only pill so a host can render its own rich trigger (icon, animated
|
|
38
|
+
* total, chevron) while the shell still owns open-state, the auth gate, and
|
|
39
|
+
* click-outside. The host renders its own button and calls `toggle` on click.
|
|
40
|
+
* Omit for the default pill (desk).
|
|
41
|
+
*/
|
|
42
|
+
trigger?: (state: {
|
|
43
|
+
open: boolean;
|
|
44
|
+
total: number;
|
|
45
|
+
toggle: () => void;
|
|
46
|
+
formatUsd: (n: number) => string;
|
|
47
|
+
}) => ReactNode;
|
|
35
48
|
/** Extra content inside the open panel — desk injects gateway/hinkal/multisig;
|
|
36
49
|
* defi-web injects its full per-chain balance body (net toggle, ghost, APY). */
|
|
37
50
|
children?: ReactNode;
|
|
@@ -61,6 +74,7 @@ export function WalletDropdown(props: WalletDropdownProps): ReactNode {
|
|
|
61
74
|
accounts,
|
|
62
75
|
scope = "all",
|
|
63
76
|
formatUsd = defaultFormatUsd,
|
|
77
|
+
trigger,
|
|
64
78
|
children,
|
|
65
79
|
renderBalances = true,
|
|
66
80
|
emptyState,
|
|
@@ -103,17 +117,23 @@ export function WalletDropdown(props: WalletDropdownProps): ReactNode {
|
|
|
103
117
|
const active = visible.find((a) => a.id === activeId) ?? visible[0];
|
|
104
118
|
const pillTotal = active ? totalUsd(active.balances) : 0;
|
|
105
119
|
|
|
120
|
+
const toggle = (): void => setOpen((v) => !v);
|
|
121
|
+
|
|
106
122
|
return (
|
|
107
123
|
<div ref={rootRef} className={classNames.root} data-bufi-wallet>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
124
|
+
{trigger ? (
|
|
125
|
+
trigger({ open, total: pillTotal, toggle, formatUsd })
|
|
126
|
+
) : (
|
|
127
|
+
<button
|
|
128
|
+
type="button"
|
|
129
|
+
aria-label="Open Stablecoin FX Wallet"
|
|
130
|
+
aria-expanded={open}
|
|
131
|
+
className={classNames.pill ?? "acct-mini"}
|
|
132
|
+
onClick={toggle}
|
|
133
|
+
>
|
|
134
|
+
{formatUsd(pillTotal)}
|
|
135
|
+
</button>
|
|
136
|
+
)}
|
|
117
137
|
|
|
118
138
|
{open && (
|
|
119
139
|
<div role="menu" className={classNames.panel} data-bufi-wallet-panel>
|