@mysten/dapp-kit-react 2.0.1 → 2.0.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/dist/index.d.mts +9 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/ui.d.mts.map +1 -1
- package/docs/actions/connect-wallet.md +6 -5
- package/docs/actions/disconnect-wallet.md +12 -10
- package/docs/actions/sign-and-execute-transaction.md +16 -15
- package/docs/actions/sign-personal-message.md +10 -9
- package/docs/actions/sign-transaction.md +9 -8
- package/docs/actions/switch-account.md +8 -7
- package/docs/actions/switch-network.md +7 -6
- package/docs/dapp-kit-instance.md +22 -22
- package/docs/getting-started/create-dapp.md +13 -13
- package/docs/getting-started/next-js.md +14 -13
- package/docs/getting-started/react.md +29 -27
- package/docs/getting-started/vue.md +20 -15
- package/docs/index.md +10 -10
- package/docs/llms-index.md +30 -31
- package/docs/react/components/connect-button.md +4 -4
- package/docs/react/components/connect-modal.md +4 -4
- package/docs/react/components/index.md +3 -3
- package/docs/react/dapp-kit-provider.md +7 -7
- package/docs/react/hooks/index.md +5 -4
- package/docs/react/hooks/use-current-account.md +4 -4
- package/docs/react/hooks/use-current-client.md +7 -7
- package/docs/react/hooks/use-current-network.md +4 -4
- package/docs/react/hooks/use-current-wallet.md +4 -4
- package/docs/react/hooks/use-dapp-kit.md +6 -6
- package/docs/react/hooks/use-wallet-connection.md +4 -4
- package/docs/react/hooks/use-wallets.md +4 -4
- package/docs/state.md +18 -17
- package/docs/theming.md +32 -32
- package/docs/web-components/connect-button.md +13 -11
- package/docs/web-components/connect-modal.md +18 -17
- package/package.json +3 -5
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# useCurrentNetwork
|
|
2
2
|
|
|
3
|
-
> React hook to get the
|
|
3
|
+
> React hook to get the currently selected Sui network in dApp Kit.
|
|
4
4
|
|
|
5
5
|
The `useCurrentNetwork` hook provides access to the currently selected network.
|
|
6
6
|
|
|
7
7
|
> **Warning:** All dApp Kit hooks must be used within components that are descendants of
|
|
8
|
-
> [DAppKitProvider](../dapp-kit-provider). Using them outside will result in an error.
|
|
8
|
+
> [`DAppKitProvider`](../dapp-kit-provider). Using them outside will result in an error.
|
|
9
9
|
|
|
10
10
|
## Usage
|
|
11
11
|
|
|
@@ -21,8 +21,8 @@ The `useCurrentNetwork` hook provides access to the currently selected network.
|
|
|
21
21
|
}
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
## Return
|
|
24
|
+
## Return value
|
|
25
25
|
|
|
26
26
|
```tsx
|
|
27
27
|
string;
|
|
28
|
-
```
|
|
28
|
+
```
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# useCurrentWallet
|
|
2
2
|
|
|
3
|
-
> React hook to get the
|
|
3
|
+
> React hook to get the currently connected wallet in a Sui dApp.
|
|
4
4
|
|
|
5
5
|
The `useCurrentWallet` hook provides access to the currently connected wallet.
|
|
6
6
|
|
|
7
7
|
> **Warning:** All dApp Kit hooks must be used within components that are descendants of
|
|
8
|
-
> [DAppKitProvider](../dapp-kit-provider). Using them outside will result in an error.
|
|
8
|
+
> [`DAppKitProvider`](../dapp-kit-provider). Using them outside will result in an error.
|
|
9
9
|
|
|
10
10
|
## Usage
|
|
11
11
|
|
|
@@ -29,8 +29,8 @@ The `useCurrentWallet` hook provides access to the currently connected wallet.
|
|
|
29
29
|
}
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
## Return
|
|
32
|
+
## Return value
|
|
33
33
|
|
|
34
34
|
```tsx
|
|
35
35
|
UiWallet | null;
|
|
36
|
-
```
|
|
36
|
+
```
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# useDAppKit
|
|
2
2
|
|
|
3
|
-
> React hook to access the full dApp Kit instance
|
|
3
|
+
> React hook to access the full dApp Kit instance for calling actions directly.
|
|
4
4
|
|
|
5
5
|
The `useDAppKit` hook provides direct access to the dApp Kit instance within React components,
|
|
6
6
|
enabling you to call actions and access the underlying functionality.
|
|
7
7
|
|
|
8
8
|
> **Warning:** All dApp Kit hooks must be used within components that are descendants of
|
|
9
|
-
> [DAppKitProvider](../dapp-kit-provider). Using them outside will result in an error.
|
|
9
|
+
> [`DAppKitProvider`](../dapp-kit-provider). Using them outside will result in an error.
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
@@ -27,7 +27,7 @@ enabling you to call actions and access the underlying functionality.
|
|
|
27
27
|
}
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
## Return
|
|
30
|
+
## Return value
|
|
31
31
|
|
|
32
32
|
```ts
|
|
33
33
|
{
|
|
@@ -54,7 +54,7 @@ enabling you to call actions and access the underlying functionality.
|
|
|
54
54
|
|
|
55
55
|
## Examples
|
|
56
56
|
|
|
57
|
-
### Transaction
|
|
57
|
+
### Transaction execution
|
|
58
58
|
|
|
59
59
|
```tsx
|
|
60
60
|
|
|
@@ -83,7 +83,7 @@ enabling you to call actions and access the underlying functionality.
|
|
|
83
83
|
}
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
### Subscribing to
|
|
86
|
+
### Subscribing to state changes
|
|
87
87
|
|
|
88
88
|
```tsx
|
|
89
89
|
|
|
@@ -97,4 +97,4 @@ enabling you to call actions and access the underlying functionality.
|
|
|
97
97
|
}, [dAppKit]);
|
|
98
98
|
return null;
|
|
99
99
|
}
|
|
100
|
-
```
|
|
100
|
+
```
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# useWalletConnection
|
|
2
2
|
|
|
3
|
-
> React hook to manage wallet connection and
|
|
3
|
+
> React hook to manage wallet connection status and information in a Sui dApp.
|
|
4
4
|
|
|
5
5
|
The `useWalletConnection` hook provides access to the current wallet connection status and
|
|
6
6
|
information.
|
|
7
7
|
|
|
8
8
|
> **Warning:** All dApp Kit hooks must be used within components that are descendants of
|
|
9
|
-
> [DAppKitProvider](../dapp-kit-provider). Using them outside will result in an error.
|
|
9
|
+
> [`DAppKitProvider`](../dapp-kit-provider). Using them outside will result in an error.
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
@@ -32,7 +32,7 @@ information.
|
|
|
32
32
|
}
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
## Return
|
|
35
|
+
## Return value
|
|
36
36
|
|
|
37
37
|
```tsx
|
|
38
38
|
{
|
|
@@ -45,4 +45,4 @@ information.
|
|
|
45
45
|
isReconnecting: boolean;
|
|
46
46
|
isDisconnected: boolean;
|
|
47
47
|
}
|
|
48
|
-
```
|
|
48
|
+
```
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# useWallets
|
|
2
2
|
|
|
3
|
-
> React hook to list available wallets
|
|
3
|
+
> React hook to list all available Sui wallets detected by dApp Kit.
|
|
4
4
|
|
|
5
5
|
The `useWallets` hook provides access to all available wallets.
|
|
6
6
|
|
|
7
7
|
> **Warning:** All dApp Kit hooks must be used within components that are descendants of
|
|
8
|
-
> [DAppKitProvider](../dapp-kit-provider). Using them outside will result in an error.
|
|
8
|
+
> [`DAppKitProvider`](../dapp-kit-provider). Using them outside will result in an error.
|
|
9
9
|
|
|
10
10
|
## Usage
|
|
11
11
|
|
|
@@ -26,8 +26,8 @@ The `useWallets` hook provides access to all available wallets.
|
|
|
26
26
|
}
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
## Return
|
|
29
|
+
## Return value
|
|
30
30
|
|
|
31
31
|
```tsx
|
|
32
32
|
UiWallet[]
|
|
33
|
-
```
|
|
33
|
+
```
|
package/docs/state.md
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
# State
|
|
2
2
|
|
|
3
|
-
> Access and subscribe to wallet connection state in dApp Kit
|
|
3
|
+
> Access and subscribe to wallet connection state in dApp Kit.
|
|
4
4
|
|
|
5
5
|
The Sui dApp Kit SDK uses [nanostores](https://github.com/nanostores/nanostores) for state
|
|
6
6
|
management, providing a lightweight, framework-agnostic solution that works across React, Vue,
|
|
7
7
|
Vanilla JavaScript, and other frameworks.
|
|
8
8
|
|
|
9
|
-
## Available
|
|
9
|
+
## Available stores
|
|
10
10
|
|
|
11
11
|
The dApp Kit exposes four reactive stores that you can subscribe to:
|
|
12
12
|
|
|
13
|
-
- **`$connection
|
|
14
|
-
- **`$currentNetwork
|
|
15
|
-
- **`$currentClient
|
|
16
|
-
- **`$wallets
|
|
13
|
+
- **`$connection`:** Current wallet connection state
|
|
14
|
+
- **`$currentNetwork`:** Currently selected network
|
|
15
|
+
- **`$currentClient`:** Client instance for the current network
|
|
16
|
+
- **`$wallets`:** List of available wallets
|
|
17
17
|
|
|
18
|
-
## Accessing
|
|
18
|
+
## Accessing stores
|
|
19
19
|
|
|
20
20
|
All stores are available through the `dAppKit.stores` property:
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
|
+
|
|
23
24
|
const dAppKit = createDAppKit({
|
|
24
25
|
/* config */
|
|
25
26
|
});
|
|
@@ -31,7 +32,7 @@ const client = dAppKit.stores.$currentClient.get();
|
|
|
31
32
|
const wallets = dAppKit.stores.$wallets.get();
|
|
32
33
|
```
|
|
33
34
|
|
|
34
|
-
## Subscribing to
|
|
35
|
+
## Subscribing to state changes
|
|
35
36
|
|
|
36
37
|
Subscribe to any store to react to state changes:
|
|
37
38
|
|
|
@@ -50,9 +51,9 @@ const unsubscribe = dAppKit.stores.$connection.subscribe((connection) => {
|
|
|
50
51
|
unsubscribe();
|
|
51
52
|
```
|
|
52
53
|
|
|
53
|
-
## Store
|
|
54
|
+
## Store details
|
|
54
55
|
|
|
55
|
-
### Connection
|
|
56
|
+
### Connection store (`$connection`)
|
|
56
57
|
|
|
57
58
|
Contains the current wallet connection state with status flags:
|
|
58
59
|
|
|
@@ -82,7 +83,7 @@ if (connection.isConnected && connection.wallet && connection.account) {
|
|
|
82
83
|
}
|
|
83
84
|
```
|
|
84
85
|
|
|
85
|
-
### Current
|
|
86
|
+
### Current network store (`$currentNetwork`)
|
|
86
87
|
|
|
87
88
|
Contains the currently selected network as a string:
|
|
88
89
|
|
|
@@ -95,9 +96,9 @@ dAppKit.stores.$currentNetwork.subscribe((network) => {
|
|
|
95
96
|
});
|
|
96
97
|
```
|
|
97
98
|
|
|
98
|
-
|
|
99
|
+
This store is read-only. Use `dAppKit.switchNetwork()` to change networks.
|
|
99
100
|
|
|
100
|
-
### Current
|
|
101
|
+
### Current client store (`$currentClient`)
|
|
101
102
|
|
|
102
103
|
Contains the SuiClient instance for the current network:
|
|
103
104
|
|
|
@@ -110,9 +111,9 @@ const balance = await client.getBalance({
|
|
|
110
111
|
});
|
|
111
112
|
```
|
|
112
113
|
|
|
113
|
-
|
|
114
|
+
This store automatically updates when the network changes.
|
|
114
115
|
|
|
115
|
-
### Wallets
|
|
116
|
+
### Wallets store (`$wallets`)
|
|
116
117
|
|
|
117
118
|
Contains the list of available wallets:
|
|
118
119
|
|
|
@@ -125,7 +126,7 @@ wallets.forEach((wallet) => {
|
|
|
125
126
|
});
|
|
126
127
|
```
|
|
127
128
|
|
|
128
|
-
## Subscribing to
|
|
129
|
+
## Subscribing to state changes
|
|
129
130
|
|
|
130
131
|
You can subscribe directly to stores:
|
|
131
132
|
|
|
@@ -165,4 +166,4 @@ const networks = dAppKit.networks; // ['mainnet', 'testnet', ...]
|
|
|
165
166
|
// Get client for specific network
|
|
166
167
|
const mainnetClient = dAppKit.getClient('mainnet');
|
|
167
168
|
const currentClient = dAppKit.getClient(); // Current network's client
|
|
168
|
-
```
|
|
169
|
+
```
|
package/docs/theming.md
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
# Theming
|
|
2
2
|
|
|
3
|
-
> Customize the appearance of dApp Kit UI components
|
|
3
|
+
> Customize the appearance of dApp Kit UI components.
|
|
4
4
|
|
|
5
5
|
The dApp Kit web components use a theming system compatible with
|
|
6
6
|
[shadcn/ui](https://ui.shadcn.com/docs/theming). Components are customized using CSS custom
|
|
7
7
|
properties (CSS variables), allowing you to match them to your application's design system.
|
|
8
8
|
|
|
9
|
-
> **Note:** **shadcn/ui Compatibility**: The dApp Kit uses the same CSS custom property naming
|
|
10
|
-
>
|
|
11
|
-
>
|
|
12
|
-
>
|
|
9
|
+
> **Note:** **shadcn/ui Compatibility**: The dApp Kit uses the same CSS custom property naming convention as
|
|
10
|
+
> shadcn/ui. If your application already uses shadcn/ui themes, the dApp Kit components will
|
|
11
|
+
> automatically inherit your theme. You can also use [shadcn/ui's theme
|
|
12
|
+
> builder](https://ui.shadcn.com/themes) to create custom themes.
|
|
13
13
|
|
|
14
|
-
## CSS
|
|
14
|
+
## CSS custom properties
|
|
15
15
|
|
|
16
16
|
All dApp Kit web components support the following CSS custom properties:
|
|
17
17
|
|
|
18
18
|
### Colors
|
|
19
19
|
|
|
20
20
|
These color variables follow the shadcn/ui naming convention. Colors can be defined using any valid
|
|
21
|
-
CSS color format (hex, rgb, hsl, oklch,
|
|
21
|
+
CSS color format (hex, rgb, hsl, oklch, and others).
|
|
22
22
|
|
|
23
|
-
- **`--background
|
|
23
|
+
- **`--background`:** Background color of the component. Used as the default background for UI
|
|
24
24
|
elements.
|
|
25
|
-
- **`--foreground
|
|
26
|
-
- **`--primary
|
|
27
|
-
- **`--primary-foreground
|
|
28
|
-
- **`--secondary
|
|
29
|
-
- **`--secondary-foreground
|
|
30
|
-
- **`--border
|
|
31
|
-
- **`--accent
|
|
32
|
-
- **`--accent-foreground
|
|
33
|
-
- **`--muted
|
|
34
|
-
states).
|
|
35
|
-
- **`--muted-foreground
|
|
36
|
-
- **`--popover
|
|
37
|
-
- **`--popover-foreground
|
|
38
|
-
- **`--ring
|
|
25
|
+
- **`--foreground`:** Foreground color of the component. Used as the default text color.
|
|
26
|
+
- **`--primary`:** Primary color used for interactive elements such as buttons and links.
|
|
27
|
+
- **`--primary-foreground`:** Text or icon color placed on top of primary elements.
|
|
28
|
+
- **`--secondary`:** Secondary color used for less prominent interactive elements.
|
|
29
|
+
- **`--secondary-foreground`:** Text or icon color placed on top of secondary elements.
|
|
30
|
+
- **`--border`:** Border color for UI elements.
|
|
31
|
+
- **`--accent`:** Accent color used for highlights and decorative elements.
|
|
32
|
+
- **`--accent-foreground`:** Text or icon color placed on top of accent elements.
|
|
33
|
+
- **`--muted`:** Background color for subtle or muted UI elements (for example, placeholders and
|
|
34
|
+
disabled states).
|
|
35
|
+
- **`--muted-foreground`:** Text or icon color for muted UI elements.
|
|
36
|
+
- **`--popover`:** Background color for floating elements such as popovers, dropdowns, or tooltips.
|
|
37
|
+
- **`--popover-foreground`:** Text or icon color inside popover elements.
|
|
38
|
+
- **`--ring`:** Color used for focus rings (visible focus indicators on interactive elements).
|
|
39
39
|
|
|
40
40
|
### Typography
|
|
41
41
|
|
|
42
|
-
- **`--font-sans
|
|
43
|
-
- **`--font-weight-medium
|
|
42
|
+
- **`--font-sans`:** Font family used for text content.
|
|
43
|
+
- **`--font-weight-medium`:** Medium font weight for text (typically used for buttons and
|
|
44
44
|
interactive elements).
|
|
45
|
-
- **`--font-weight-semibold
|
|
45
|
+
- **`--font-weight-semibold`:** Semibold font weight for text (typically used for headings or
|
|
46
46
|
emphasized text).
|
|
47
47
|
|
|
48
48
|
### Layout
|
|
49
49
|
|
|
50
|
-
- **`--radius
|
|
50
|
+
- **`--radius`:** Border radius used for UI elements.
|
|
51
51
|
|
|
52
52
|
## Usage
|
|
53
53
|
|
|
54
|
-
### Global
|
|
54
|
+
### Global theming
|
|
55
55
|
|
|
56
56
|
Apply custom properties to affect all dApp Kit components:
|
|
57
57
|
|
|
@@ -67,7 +67,7 @@ Apply custom properties to affect all dApp Kit components:
|
|
|
67
67
|
}
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
### Component-
|
|
70
|
+
### Component-specific theming
|
|
71
71
|
|
|
72
72
|
Target specific components:
|
|
73
73
|
|
|
@@ -84,7 +84,7 @@ mysten-dapp-kit-connect-modal {
|
|
|
84
84
|
}
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
### Dark
|
|
87
|
+
### Dark mode
|
|
88
88
|
|
|
89
89
|
Implement dark mode by overriding the custom properties:
|
|
90
90
|
|
|
@@ -126,7 +126,7 @@ Or use a class-based approach:
|
|
|
126
126
|
</div>
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
-
## Example:
|
|
129
|
+
## Example: complete theme
|
|
130
130
|
|
|
131
131
|
Here's a complete theme example matching a custom design system:
|
|
132
132
|
|
|
@@ -159,7 +159,7 @@ Here's a complete theme example matching a custom design system:
|
|
|
159
159
|
}
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
-
## Framework
|
|
162
|
+
## Framework integration
|
|
163
163
|
|
|
164
164
|
### React
|
|
165
165
|
|
|
@@ -193,4 +193,4 @@ Here's a complete theme example matching a custom design system:
|
|
|
193
193
|
<mysten-dapp-kit-connect-button></mysten-dapp-kit-connect-button>
|
|
194
194
|
</body>
|
|
195
195
|
</html>
|
|
196
|
-
```
|
|
196
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Connect Button
|
|
2
2
|
|
|
3
|
-
> Framework-agnostic web component
|
|
3
|
+
> Framework-agnostic web component providing a complete wallet connection UI for Sui dApps.
|
|
4
4
|
|
|
5
5
|
The `<mysten-dapp-kit-connect-button>` Web Component provides a complete wallet connection UI. It
|
|
6
6
|
displays a "Connect Wallet" button when no wallet is connected, and shows the connected account with
|
|
@@ -10,7 +10,7 @@ a menu when a wallet is active.
|
|
|
10
10
|
> page reload. This provides a seamless user experience but can be
|
|
11
11
|
> [disabled](../dapp-kit-instance#disabling-auto-connect) if needed.
|
|
12
12
|
|
|
13
|
-
## Basic
|
|
13
|
+
## Basic usage
|
|
14
14
|
|
|
15
15
|
### Vanilla
|
|
16
16
|
|
|
@@ -26,7 +26,9 @@ a menu when a wallet is active.
|
|
|
26
26
|
### Vue
|
|
27
27
|
|
|
28
28
|
```vue
|
|
29
|
-
<script setup
|
|
29
|
+
<script setup>
|
|
30
|
+
|
|
31
|
+
</script>
|
|
30
32
|
|
|
31
33
|
<template>
|
|
32
34
|
<mysten-dapp-kit-connect-button :instance="dAppKit" />
|
|
@@ -49,12 +51,12 @@ The connect button component automatically handles:
|
|
|
49
51
|
|
|
50
52
|
## Properties
|
|
51
53
|
|
|
52
|
-
- **instance
|
|
54
|
+
- **instance:** The dApp Kit instance
|
|
53
55
|
- **modalOptions** (optional) - Configuration options for the connect modal
|
|
54
|
-
- `filterFn
|
|
55
|
-
- `sortFn
|
|
56
|
+
- `filterFn`: Function to filter available wallets
|
|
57
|
+
- `sortFn`: Function to sort available wallets
|
|
56
58
|
|
|
57
|
-
## Custom
|
|
59
|
+
## Custom button text
|
|
58
60
|
|
|
59
61
|
Use the default slot to customize the button text when not connected:
|
|
60
62
|
|
|
@@ -64,12 +66,12 @@ Use the default slot to customize the button text when not connected:
|
|
|
64
66
|
</mysten-dapp-kit-connect-button>
|
|
65
67
|
```
|
|
66
68
|
|
|
67
|
-
## Modal
|
|
69
|
+
## Modal integration
|
|
68
70
|
|
|
69
71
|
The connect button automatically manages its own modal. You don't need to add a separate
|
|
70
72
|
`<mysten-dapp-kit-connect-modal>` component when using the connect button.
|
|
71
73
|
|
|
72
|
-
## Connected
|
|
74
|
+
## Connected state
|
|
73
75
|
|
|
74
76
|
When a wallet is connected, the button transforms into an account menu that displays:
|
|
75
77
|
|
|
@@ -81,7 +83,7 @@ When a wallet is connected, the button transforms into an account menu that disp
|
|
|
81
83
|
- Managing connection
|
|
82
84
|
- Disconnecting
|
|
83
85
|
|
|
84
|
-
## Server-
|
|
86
|
+
## Server-side rendering (SSR)
|
|
85
87
|
|
|
86
88
|
The `<mysten-dapp-kit-connect-button>` Web Component can be only client-side rendered, as wallets
|
|
87
|
-
are detected in the browser. For Next.js guide see [here](../getting-started/next-js).
|
|
89
|
+
are detected in the browser. For Next.js guide see [here](../getting-started/next-js).
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
# Connect Modal
|
|
2
2
|
|
|
3
|
-
> Framework-agnostic web component for wallet selection
|
|
3
|
+
> Framework-agnostic web component for wallet selection and connection in Sui dApps.
|
|
4
4
|
|
|
5
5
|
The `<mysten-dapp-kit-connect-modal>` Web Component provides a modal dialog for wallet connection.
|
|
6
6
|
While most apps should use the [`Connect Button`](./connect-button) which includes an integrated
|
|
7
7
|
modal, the standalone modal is useful for advanced scenarios requiring custom trigger mechanisms.
|
|
8
8
|
|
|
9
|
-
## When to
|
|
9
|
+
## When to use
|
|
10
10
|
|
|
11
11
|
Use the standalone modal when you need:
|
|
12
12
|
|
|
13
|
-
- **Custom trigger elements
|
|
14
|
-
- **Complex UI flows
|
|
15
|
-
- **Programmatic control
|
|
16
|
-
- **Multiple triggers
|
|
13
|
+
- **Custom trigger elements:** Menu items, keyboard shortcuts, or other non-button triggers
|
|
14
|
+
- **Complex UI flows:** Integration into existing navigation or custom wallet management interfaces
|
|
15
|
+
- **Programmatic control:** Opening the modal based on application logic or user actions
|
|
16
|
+
- **Multiple triggers:** Different parts of your UI that can open the same modal
|
|
17
17
|
|
|
18
18
|
For standard wallet connection with a button, use the [Connect Button](./connect-button) component
|
|
19
19
|
instead.
|
|
20
20
|
|
|
21
|
-
## Basic
|
|
21
|
+
## Basic usage
|
|
22
22
|
|
|
23
23
|
### Vanilla
|
|
24
24
|
|
|
@@ -58,6 +58,7 @@ instead.
|
|
|
58
58
|
|
|
59
59
|
```vue
|
|
60
60
|
<script setup lang="ts">
|
|
61
|
+
|
|
61
62
|
const modalRef = ref();
|
|
62
63
|
const isModalOpen = ref(false);
|
|
63
64
|
|
|
@@ -89,8 +90,8 @@ DApp Kit React bindings provide a [React wrapper](../react/components/connect-mo
|
|
|
89
90
|
|
|
90
91
|
## Properties
|
|
91
92
|
|
|
92
|
-
- **instance
|
|
93
|
-
- **open
|
|
93
|
+
- **instance:** The dApp Kit instance
|
|
94
|
+
- **open:** Boolean to control modal visibility programmatically
|
|
94
95
|
- **filterFn** (optional) - Function to filter available wallets
|
|
95
96
|
- Type: `(wallet: UiWallet, index: number, array: UiWallet[]) => boolean`
|
|
96
97
|
- **sortFn** (optional) - Function to sort available wallets
|
|
@@ -120,11 +121,11 @@ await modal?.close('user-cancelled');
|
|
|
120
121
|
|
|
121
122
|
The modal fires several events during its lifecycle:
|
|
122
123
|
|
|
123
|
-
- **open
|
|
124
|
-
- **opened
|
|
125
|
-
- **close
|
|
126
|
-
- **closed
|
|
127
|
-
- **cancel
|
|
124
|
+
- **open:** Fired before the modal opens (cancelable)
|
|
125
|
+
- **opened:** Fired after the modal has fully opened
|
|
126
|
+
- **close:** Fired before the modal closes (cancelable)
|
|
127
|
+
- **closed:** Fired after the modal has fully closed
|
|
128
|
+
- **cancel:** Fired when clicking backdrop or pressing Escape (cancelable)
|
|
128
129
|
|
|
129
130
|
```js
|
|
130
131
|
const modal = document.querySelector('mysten-dapp-kit-connect-modal');
|
|
@@ -150,7 +151,7 @@ modal?.addEventListener('cancel', (event) => {
|
|
|
150
151
|
|
|
151
152
|
## Examples
|
|
152
153
|
|
|
153
|
-
### Programmatic
|
|
154
|
+
### Programmatic control
|
|
154
155
|
|
|
155
156
|
```js
|
|
156
157
|
const modal = document.querySelector('mysten-dapp-kit-connect-modal');
|
|
@@ -170,7 +171,7 @@ async function performAction() {
|
|
|
170
171
|
}
|
|
171
172
|
```
|
|
172
173
|
|
|
173
|
-
## Server-
|
|
174
|
+
## Server-side rendering (SSR)
|
|
174
175
|
|
|
175
176
|
The `<mysten-dapp-kit-connect-modal>` Web Component can be only client-side rendered, as wallets are
|
|
176
|
-
detected in the browser. For Next.js guide see [here](../getting-started/next-js).
|
|
177
|
+
detected in the browser. For Next.js guide see [here](../getting-started/next-js).
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@mysten/dapp-kit-react",
|
|
3
3
|
"author": "Mysten Labs <build@mystenlabs.com>",
|
|
4
4
|
"description": "React bindings for @mysten/dapp-kit-core",
|
|
5
|
-
"version": "2.0.
|
|
5
|
+
"version": "2.0.3",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"files": [
|
|
8
8
|
"LICENSE",
|
|
@@ -37,8 +37,6 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/react": "^19.2.8",
|
|
41
|
-
"react": "^19.2.3",
|
|
42
40
|
"tsdown": "0.20.0-beta.1",
|
|
43
41
|
"typescript": "^5.9.3"
|
|
44
42
|
},
|
|
@@ -46,7 +44,7 @@
|
|
|
46
44
|
"@lit/react": "^1.0.8",
|
|
47
45
|
"@nanostores/react": "^1.0.0",
|
|
48
46
|
"nanostores": "^1.1.0",
|
|
49
|
-
"@mysten/dapp-kit-core": "^1.2
|
|
47
|
+
"@mysten/dapp-kit-core": "^1.3.2"
|
|
50
48
|
},
|
|
51
49
|
"peerDependencies": {
|
|
52
50
|
"@types/react": ">=17.0.0",
|
|
@@ -55,7 +53,7 @@
|
|
|
55
53
|
"scripts": {
|
|
56
54
|
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|
|
57
55
|
"build": "pnpm typecheck && tsdown",
|
|
58
|
-
"build:docs": "
|
|
56
|
+
"build:docs": "node ../../../docs/scripts/build-docs.ts",
|
|
59
57
|
"typecheck": "tsc --noEmit",
|
|
60
58
|
"dev": "tsdown --watch",
|
|
61
59
|
"prettier:check": "prettier -c --ignore-unknown .",
|