@reclack/walletkit 0.1.2 → 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 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
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 {
@@ -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;