@reclack/walletkit 0.1.2 → 0.2.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 +33 -0
- package/assets/base.webp +0 -0
- package/assets/ethereum.webp +0 -0
- package/assets/polygon.webp +0 -0
- package/assets/solana.webp +0 -0
- package/dist/element/element.d.ts +8 -0
- package/dist/element/index.d.ts +3 -1
- package/dist/element/network-element.d.ts +24 -0
- package/dist/element/props.d.ts +36 -0
- package/dist/element/ui/assets.d.ts +2 -0
- package/dist/element/ui/network-select.d.ts +17 -0
- package/dist/element.js +680 -413
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/networks.d.ts +5 -0
- package/dist/networks.d.ts.map +1 -0
- package/dist/networks.js +41 -0
- package/dist/networks.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -161,6 +161,39 @@ by setting any `--rkw-` token on the element.
|
|
|
161
161
|
`variant="modal"` is a native `<dialog>`, so focus trapping, Esc to close, an
|
|
162
162
|
inert background and a backdrop all come from the browser.
|
|
163
163
|
|
|
164
|
+
## The network picker
|
|
165
|
+
|
|
166
|
+
The chain something settles on, as a second element. A checkout asks which
|
|
167
|
+
chain before it asks which wallet, and a form collecting a settlement address
|
|
168
|
+
asks which chain without connecting anything at all.
|
|
169
|
+
|
|
170
|
+
```html
|
|
171
|
+
<reclack-network
|
|
172
|
+
networks="base,polygon,ethereum,solana"
|
|
173
|
+
value="base"
|
|
174
|
+
asset-base="/wallets/"
|
|
175
|
+
></reclack-network>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
document.querySelector('reclack-network')
|
|
180
|
+
.addEventListener('change', (event) => {
|
|
181
|
+
console.log(event.detail.network) // 'polygon'
|
|
182
|
+
})
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
| Attribute | Values | Default | What it does |
|
|
186
|
+
| --- | --- | --- | --- |
|
|
187
|
+
| `networks` | comma separated names | none | The chains to choose between |
|
|
188
|
+
| `value` | one of them | the first | The chain chosen, and settable |
|
|
189
|
+
| `disabled` | present or absent | absent | Stops it while something is in flight |
|
|
190
|
+
| `label` | text | `Network` | Empty renders no label at all |
|
|
191
|
+
| `asset-base` | URL path | `/images/` | Where the chain marks are served from |
|
|
192
|
+
|
|
193
|
+
It carries the same theme attributes as the picker, and `element.value` reads
|
|
194
|
+
and writes the choice. Chain artwork ships in `assets/` beside the wallet
|
|
195
|
+
artwork; a chain with no mark shows its initial rather than a broken image.
|
|
196
|
+
|
|
164
197
|
## The kit
|
|
165
198
|
|
|
166
199
|
The element makes its own kit, and you never have to touch one. Reach for the
|
package/assets/base.webp
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -68,6 +68,14 @@ export declare class ReclackConnectElement extends HTMLElement {
|
|
|
68
68
|
/** Hands this element a kit to share instead of the one it would make. */
|
|
69
69
|
useKit(kit: WalletKit): void;
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Puts the stylesheet in the shadow root.
|
|
73
|
+
*
|
|
74
|
+
* One constructed sheet shared by every instance, so a page with several
|
|
75
|
+
* pickers parses the CSS once. A `<style>` element where that is not
|
|
76
|
+
* supported, which costs a parse per element and is correct everywhere.
|
|
77
|
+
*/
|
|
78
|
+
export declare function adoptStyles(root: ShadowRoot): void;
|
|
71
79
|
/** Registers the element, once, under its own name. */
|
|
72
80
|
export declare function defineWalletElement(tagName?: string): void;
|
|
73
81
|
export interface ConnectWalletOptions extends ConnectRequest {
|
package/dist/element/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type { ReclackConnectAttributes, ReclackConnectProps, } from './attributes.js';
|
|
2
2
|
export { ATTRIBUTES, attributesOf, EVENTS } from './props.js';
|
|
3
|
-
export
|
|
3
|
+
export { NETWORK_ATTRIBUTES, NETWORK_EVENTS, networkAttributesOf, } from './props.js';
|
|
4
|
+
export type { ConnectProps, NetworkProps } from './props.js';
|
|
4
5
|
export { connectWallet, defineWalletElement, ReclackConnectElement, type ConnectWalletOptions, } from './element.js';
|
|
6
|
+
export { defineNetworkElement, ReclackNetworkElement, } from './network-element.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { WalletKitTheme } from '@reclack/walletkit';
|
|
2
|
+
/**
|
|
3
|
+
* The chain picker, as an element of its own.
|
|
4
|
+
*
|
|
5
|
+
* Separate from `<reclack-connect>` because the two answer different
|
|
6
|
+
* questions and a page often wants one without the other: a checkout asks
|
|
7
|
+
* which chain before it asks which wallet, and a dashboard form asks which
|
|
8
|
+
* chain an address is for without connecting anything at all.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ReclackNetworkElement extends HTMLElement {
|
|
11
|
+
#private;
|
|
12
|
+
static tagName: string;
|
|
13
|
+
static get observedAttributes(): string[];
|
|
14
|
+
constructor();
|
|
15
|
+
/** The full theme, for anything an attribute cannot hold. */
|
|
16
|
+
set theme(theme: WalletKitTheme | undefined);
|
|
17
|
+
/** The chain currently chosen, which is also settable. */
|
|
18
|
+
get value(): string;
|
|
19
|
+
set value(network: string);
|
|
20
|
+
connectedCallback(): void;
|
|
21
|
+
disconnectedCallback(): void;
|
|
22
|
+
attributeChangedCallback(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare function defineNetworkElement(tagName?: string): void;
|
package/dist/element/props.d.ts
CHANGED
|
@@ -65,3 +65,39 @@ export declare const EVENTS: {
|
|
|
65
65
|
readonly cancel: "onCancel";
|
|
66
66
|
readonly 'connect-error': "onError";
|
|
67
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* The chain picker's props, and how each becomes an attribute.
|
|
70
|
+
*
|
|
71
|
+
* Shared for the same reason the picker's are: two wrappers writing their own
|
|
72
|
+
* mapping is two mappings to keep in step with the element.
|
|
73
|
+
*/
|
|
74
|
+
export interface NetworkProps {
|
|
75
|
+
/** The chains to choose between, in the order they are offered. */
|
|
76
|
+
networks?: string[] | string;
|
|
77
|
+
/** The chain chosen. The first is used when this names none of them. */
|
|
78
|
+
value?: string;
|
|
79
|
+
/** Empty renders no label at all. */
|
|
80
|
+
label?: string;
|
|
81
|
+
disabled?: boolean;
|
|
82
|
+
themeMode?: 'light' | 'dark' | 'system';
|
|
83
|
+
brand?: string;
|
|
84
|
+
radius?: string;
|
|
85
|
+
fontFamily?: string;
|
|
86
|
+
assetBase?: string;
|
|
87
|
+
onChange?: (network: string) => void;
|
|
88
|
+
}
|
|
89
|
+
/** The network props that are plain attributes, and their DOM names. */
|
|
90
|
+
export declare const NETWORK_ATTRIBUTES: {
|
|
91
|
+
readonly value: "value";
|
|
92
|
+
readonly label: "label";
|
|
93
|
+
readonly themeMode: "theme-mode";
|
|
94
|
+
readonly brand: "brand";
|
|
95
|
+
readonly radius: "radius";
|
|
96
|
+
readonly fontFamily: "font";
|
|
97
|
+
readonly assetBase: "asset-base";
|
|
98
|
+
};
|
|
99
|
+
export declare function networkAttributesOf(props: NetworkProps): Record<string, string>;
|
|
100
|
+
/** The one event the chain picker dispatches. */
|
|
101
|
+
export declare const NETWORK_EVENTS: {
|
|
102
|
+
readonly change: "onChange";
|
|
103
|
+
};
|
|
@@ -3,5 +3,7 @@ export declare function AssetProvider({ base, children, }: {
|
|
|
3
3
|
base: string;
|
|
4
4
|
children: ComponentChildren;
|
|
5
5
|
}): import("preact").JSX.Element;
|
|
6
|
+
/** Where this element serves its artwork from, for anything drawing a mark. */
|
|
7
|
+
export declare function useAssetBase(): string;
|
|
6
8
|
/** The artwork for a wallet, or nothing where this package carries none. */
|
|
7
9
|
export declare function useWalletLogo(): (id: string) => string | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chain something settles on.
|
|
3
|
+
*
|
|
4
|
+
* A closed trigger rather than a stacked list: the number of payable chains
|
|
5
|
+
* grows with every deployment, and a list that grows without bound pushes
|
|
6
|
+
* whatever follows it below the fold.
|
|
7
|
+
*
|
|
8
|
+
* A combobox over a button and a listbox rather than a native `<select>`,
|
|
9
|
+
* which cannot carry a chain mark or a search field.
|
|
10
|
+
*/
|
|
11
|
+
export declare function NetworkSelect({ networks, value, disabled, label, onChange, }: {
|
|
12
|
+
networks: string[];
|
|
13
|
+
value: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
label?: string;
|
|
16
|
+
onChange: (network: string) => void;
|
|
17
|
+
}): import("preact").JSX.Element;
|