@reclack/walletkit 0.1.1 → 0.2.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 +63 -4
- 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 +1 -0
- package/dist/element/network-element.d.ts +24 -0
- package/dist/element/ui/assets.d.ts +2 -0
- package/dist/element/ui/network-select.d.ts +17 -0
- package/dist/element.js +693 -443
- 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
|
@@ -125,12 +125,9 @@ this package, so the tag and its attributes autocomplete without a wrapper.
|
|
|
125
125
|
| `chain-id` | number | none | Require this chain, switching the wallet if needed |
|
|
126
126
|
| `intent` | `address`, `balance`, comma separated | `address` | What to return |
|
|
127
127
|
| `keep-alive` | present or absent | absent | Stay connected after resolving |
|
|
128
|
-
| `theme-mode` | `light`, `dark`, `system` | `system` | Which palette to wear |
|
|
129
|
-
| `brand` | `#rrggbb` | Reclack's | Your colour, worn by the primary action |
|
|
130
|
-
| `radius` | CSS length | `10px` | Corner radius |
|
|
131
|
-
| `font` | CSS font stack | inherited | Type |
|
|
132
128
|
| `asset-base` | URL path | `/images/` | Where the wallet logos are served from |
|
|
133
129
|
| `api-url` | URL | Reclack's | A different deployment, such as a sandbox |
|
|
130
|
+
| `theme` | `WalletKitTheme`, as a property | none | Colours, radius and type. See [Theming](#theming) |
|
|
134
131
|
|
|
135
132
|
### Properties
|
|
136
133
|
|
|
@@ -164,6 +161,39 @@ by setting any `--rkw-` token on the element.
|
|
|
164
161
|
`variant="modal"` is a native `<dialog>`, so focus trapping, Esc to close, an
|
|
165
162
|
inert background and a backdrop all come from the browser.
|
|
166
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
|
+
|
|
167
197
|
## The kit
|
|
168
198
|
|
|
169
199
|
The element makes its own kit, and you never have to touch one. Reach for the
|
|
@@ -288,6 +318,35 @@ createWalletKit({
|
|
|
288
318
|
})
|
|
289
319
|
```
|
|
290
320
|
|
|
321
|
+
On the element, set it as a property:
|
|
322
|
+
|
|
323
|
+
```ts
|
|
324
|
+
element.theme = { mode: 'dark', brand: '#ff6600', radius: '14px' }
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Theme attributes
|
|
328
|
+
|
|
329
|
+
A nested object will not fit in an attribute, so the four values a plain HTML
|
|
330
|
+
page is most likely to want have one each. They build the same theme:
|
|
331
|
+
|
|
332
|
+
| Attribute | Theme field | Values | Default |
|
|
333
|
+
| --- | --- | --- | --- |
|
|
334
|
+
| `theme-mode` | `mode` | `light`, `dark`, `system` | `system` |
|
|
335
|
+
| `brand` | `brand` | `#rrggbb` | Reclack's |
|
|
336
|
+
| `radius` | `radius` | CSS length | `10px` |
|
|
337
|
+
| `font` | `fontFamily` | CSS font stack | inherited |
|
|
338
|
+
|
|
339
|
+
```html
|
|
340
|
+
<reclack-connect theme-mode="dark" brand="#ff6600" radius="14px"></reclack-connect>
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
**A theme wins over all four.** Setting the `theme` property, or sharing a kit
|
|
344
|
+
that already carries a theme, makes these attributes ignored and uses the
|
|
345
|
+
theme whole. That is deliberate: a checkout that themed its kit should not
|
|
346
|
+
have to theme every picker inside it as well.
|
|
347
|
+
|
|
348
|
+
### Following the reader's system
|
|
349
|
+
|
|
291
350
|
The resolved mode and the tokens are part of the state you are already
|
|
292
351
|
subscribed to, so the picker follows the reader's system without a second
|
|
293
352
|
listener:
|
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
|
@@ -2,3 +2,4 @@ export type { ReclackConnectAttributes, ReclackConnectProps, } from './attribute
|
|
|
2
2
|
export { ATTRIBUTES, attributesOf, EVENTS } from './props.js';
|
|
3
3
|
export type { ConnectProps } from './props.js';
|
|
4
4
|
export { connectWallet, defineWalletElement, ReclackConnectElement, type ConnectWalletOptions, } from './element.js';
|
|
5
|
+
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;
|
|
@@ -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;
|