@universal-everything/ui 1.0.0-dev.50f8f9d
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/LICENSE +201 -0
- package/README.md +170 -0
- package/dist/context.d.ts +19 -0
- package/dist/context.js +7 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +13 -0
- package/dist/wallet-kit-login.d.ts +43 -0
- package/dist/wallet-kit-login.js +139 -0
- package/dist/wallet-kit-provider.d.ts +39 -0
- package/dist/wallet-kit-provider.js +77 -0
- package/dist/wallet-kit-wallet-list.d.ts +62 -0
- package/dist/wallet-kit-wallet-list.js +211 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2023 LUKSO Blockchain GmbH
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# @universal-everything/ui
|
|
2
|
+
|
|
3
|
+
Framework-agnostic UI components for the universal-relayer wallet kit,
|
|
4
|
+
built with [Lit 3](https://lit.dev). Same custom elements drop into
|
|
5
|
+
React, Vue, Svelte, Astro, or plain HTML — author UI once, ship
|
|
6
|
+
everywhere.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm add @universal-everything/ui @universal-everything/sdk-core lit
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quick start (vanilla HTML)
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<script type="module">
|
|
18
|
+
import { WalletKitClient } from "@universal-everything/sdk-core";
|
|
19
|
+
import "@universal-everything/ui";
|
|
20
|
+
|
|
21
|
+
const client = new WalletKitClient({
|
|
22
|
+
baseUrl: "https://relayer.example.com",
|
|
23
|
+
getAccessToken: async () => sessionStorage.getItem("token"),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const provider = document.querySelector("wallet-kit-provider");
|
|
27
|
+
provider.client = client;
|
|
28
|
+
|
|
29
|
+
document.querySelector("wallet-kit-login").addEventListener("login-request", () => {
|
|
30
|
+
// Trigger your auth flow
|
|
31
|
+
});
|
|
32
|
+
document.querySelector("wallet-kit-wallet-list").addEventListener("wallet-select", (e) => {
|
|
33
|
+
console.log("picked", e.detail.wallet);
|
|
34
|
+
});
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<wallet-kit-provider>
|
|
38
|
+
<wallet-kit-login></wallet-kit-login>
|
|
39
|
+
<wallet-kit-wallet-list></wallet-kit-wallet-list>
|
|
40
|
+
</wallet-kit-provider>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## In React
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { WalletKitClient } from "@universal-everything/sdk-core";
|
|
47
|
+
import "@universal-everything/ui";
|
|
48
|
+
import type { WalletKitProviderElement } from "@universal-everything/ui";
|
|
49
|
+
|
|
50
|
+
function Kit() {
|
|
51
|
+
const providerRef = useRef<WalletKitProviderElement | null>(null);
|
|
52
|
+
const client = useMemo(() => new WalletKitClient({ … }), []);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (providerRef.current) providerRef.current.client = client;
|
|
55
|
+
}, [client]);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<wallet-kit-provider ref={providerRef}>
|
|
59
|
+
<wallet-kit-login
|
|
60
|
+
authenticated={authenticated || undefined}
|
|
61
|
+
user-label={user?.id}
|
|
62
|
+
/>
|
|
63
|
+
<wallet-kit-wallet-list />
|
|
64
|
+
</wallet-kit-provider>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
See `apps/demo-web/src/UiPanel.tsx` for a complete Privy integration.
|
|
70
|
+
|
|
71
|
+
## In Vue
|
|
72
|
+
|
|
73
|
+
```vue
|
|
74
|
+
<template>
|
|
75
|
+
<wallet-kit-provider ref="provider">
|
|
76
|
+
<wallet-kit-login
|
|
77
|
+
:authenticated="authenticated || undefined"
|
|
78
|
+
:user-label="userId"
|
|
79
|
+
@login-request="login"
|
|
80
|
+
@logout-request="logout"
|
|
81
|
+
/>
|
|
82
|
+
<wallet-kit-wallet-list @wallet-select="onSelect" />
|
|
83
|
+
</wallet-kit-provider>
|
|
84
|
+
</template>
|
|
85
|
+
|
|
86
|
+
<script setup>
|
|
87
|
+
import "@universal-everything/ui";
|
|
88
|
+
const provider = ref();
|
|
89
|
+
onMounted(() => { provider.value.client = myClient; });
|
|
90
|
+
</script>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## In Svelte
|
|
94
|
+
|
|
95
|
+
```svelte
|
|
96
|
+
<script>
|
|
97
|
+
import "@universal-everything/ui";
|
|
98
|
+
let provider;
|
|
99
|
+
$: if (provider) provider.client = myClient;
|
|
100
|
+
</script>
|
|
101
|
+
|
|
102
|
+
<wallet-kit-provider bind:this={provider}>
|
|
103
|
+
<wallet-kit-login
|
|
104
|
+
authenticated={authenticated || undefined}
|
|
105
|
+
user-label={userId}
|
|
106
|
+
on:login-request={login}
|
|
107
|
+
on:logout-request={logout}
|
|
108
|
+
/>
|
|
109
|
+
<wallet-kit-wallet-list on:wallet-select={onSelect} />
|
|
110
|
+
</wallet-kit-provider>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Components
|
|
114
|
+
|
|
115
|
+
### `<wallet-kit-provider>`
|
|
116
|
+
|
|
117
|
+
Holds a `WalletKitClient` and broadcasts it to descendants via
|
|
118
|
+
`@lit/context`. Set `.client` as a JS property (not an attribute — it's
|
|
119
|
+
an object).
|
|
120
|
+
|
|
121
|
+
### `<wallet-kit-login>`
|
|
122
|
+
|
|
123
|
+
Auth-agnostic login/logout button. This component never knows about
|
|
124
|
+
Privy or any other identity provider — your host app wires that.
|
|
125
|
+
|
|
126
|
+
- **Properties**: `authenticated` (bool), `user-label` (string),
|
|
127
|
+
`pending` (bool)
|
|
128
|
+
- **Events**:
|
|
129
|
+
- `login-request` — fired when the user clicks "Sign in"
|
|
130
|
+
- `logout-request` — fired when the user clicks "Logout"
|
|
131
|
+
|
|
132
|
+
### `<wallet-kit-wallet-list>`
|
|
133
|
+
|
|
134
|
+
Consumes the client from context, auto-loads `client.listWallets()`
|
|
135
|
+
on first render, renders a selectable list with `aria-selected`.
|
|
136
|
+
|
|
137
|
+
- **Properties**: `selected-wallet-id` (string) — purely visual, the
|
|
138
|
+
host owns selection state.
|
|
139
|
+
- **Methods**: `refresh()` — re-fetch on demand.
|
|
140
|
+
- **Events**: `wallet-select` with `detail: { wallet }` when a row is
|
|
141
|
+
clicked / Enter-pressed.
|
|
142
|
+
- **Slots**: `loading`, `error`, `empty` — override the default
|
|
143
|
+
messages without re-implementing the happy path.
|
|
144
|
+
|
|
145
|
+
## Theming
|
|
146
|
+
|
|
147
|
+
Shadow DOM means app-wide stylesheets don't leak in. Theme via CSS
|
|
148
|
+
custom properties on the host element:
|
|
149
|
+
|
|
150
|
+
```css
|
|
151
|
+
wallet-kit-login {
|
|
152
|
+
--wk-login-bg: #7c3aed;
|
|
153
|
+
--wk-login-fg: #fff;
|
|
154
|
+
--wk-login-radius: 1rem;
|
|
155
|
+
}
|
|
156
|
+
wallet-kit-wallet-list {
|
|
157
|
+
--wk-list-border: #e5e5e5;
|
|
158
|
+
--wk-list-primary-border: #7c3aed;
|
|
159
|
+
--wk-list-selected-bg: #f3e8ff;
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Data composables
|
|
164
|
+
|
|
165
|
+
This package handles UI. For framework-native data hooks / composables
|
|
166
|
+
/ stores, see the framework adapters:
|
|
167
|
+
|
|
168
|
+
- React → [`@universal-everything/sdk-react`](../sdk-react/)
|
|
169
|
+
- Vue 3 → [`@universal-everything/sdk-vue`](../sdk-vue/)
|
|
170
|
+
- Svelte 5 → [`@universal-everything/sdk-svelte`](../sdk-svelte/)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { WalletKitClient } from '@universal-everything/sdk-core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Lit context key for the `WalletKitClient`. `<wallet-kit-provider>`
|
|
5
|
+
* is the canonical provider; any `@consume({ context: walletKitContext })`
|
|
6
|
+
* field on a descendant custom element resolves to the client set on
|
|
7
|
+
* the provider.
|
|
8
|
+
*
|
|
9
|
+
* `createContext` keys identity by reference, so we export the single
|
|
10
|
+
* instance and re-use it across all components in this package. A
|
|
11
|
+
* Symbol-valued key would be safer if this package could be duplicated
|
|
12
|
+
* in a bundle, but our `package.json` flags `lit` / `@lit/context` as
|
|
13
|
+
* non-singletons and the cost/benefit doesn't justify it today.
|
|
14
|
+
*/
|
|
15
|
+
declare const walletKitContext: {
|
|
16
|
+
__context__: WalletKitClient | undefined;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { walletKitContext };
|
package/dist/context.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { WalletKitProviderElement } from './wallet-kit-provider.js';
|
|
2
|
+
export { WalletKitLoginElement } from './wallet-kit-login.js';
|
|
3
|
+
export { WalletKitWalletListElement } from './wallet-kit-wallet-list.js';
|
|
4
|
+
export { walletKitContext } from './context.js';
|
|
5
|
+
import 'lit';
|
|
6
|
+
import '@universal-everything/sdk-core';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "./wallet-kit-provider";
|
|
2
|
+
import "./wallet-kit-login";
|
|
3
|
+
import "./wallet-kit-wallet-list";
|
|
4
|
+
import { walletKitContext } from "./context";
|
|
5
|
+
import { WalletKitLoginElement } from "./wallet-kit-login";
|
|
6
|
+
import { WalletKitProviderElement } from "./wallet-kit-provider";
|
|
7
|
+
import { WalletKitWalletListElement } from "./wallet-kit-wallet-list";
|
|
8
|
+
export {
|
|
9
|
+
WalletKitLoginElement,
|
|
10
|
+
WalletKitProviderElement,
|
|
11
|
+
WalletKitWalletListElement,
|
|
12
|
+
walletKitContext
|
|
13
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as lit from 'lit';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Auth-agnostic login button. This component deliberately does not
|
|
6
|
+
* know about Privy / Clerk / OAuth — the host app wires whichever
|
|
7
|
+
* identity provider it uses and passes three properties:
|
|
8
|
+
*
|
|
9
|
+
* - `authenticated: boolean` — whether a user is signed in
|
|
10
|
+
* - `userLabel?: string` — short label to show while signed in
|
|
11
|
+
* (typically `did:privy:...` or an email — host chooses)
|
|
12
|
+
* - `pending?: boolean` — whether the identity provider is still
|
|
13
|
+
* initializing (shows a disabled placeholder)
|
|
14
|
+
*
|
|
15
|
+
* Emits `login-request` / `logout-request` `CustomEvent`s; the host
|
|
16
|
+
* binds those to its provider's login/logout calls. Emitting events
|
|
17
|
+
* (instead of accepting `.onLogin` callbacks) keeps the component
|
|
18
|
+
* framework-agnostic — React `onLoginRequest`, Vue `@login-request`,
|
|
19
|
+
* Svelte `on:login-request`, and `addEventListener` all route the
|
|
20
|
+
* same way.
|
|
21
|
+
*
|
|
22
|
+
* Styling: CSS custom properties `--wk-login-bg`, `--wk-login-fg`,
|
|
23
|
+
* `--wk-login-border`, `--wk-login-radius` are the theme surface.
|
|
24
|
+
* The shadow root boundary means app-wide stylesheets do NOT leak in.
|
|
25
|
+
*/
|
|
26
|
+
declare class WalletKitLoginElement extends LitElement {
|
|
27
|
+
static styles: lit.CSSResult;
|
|
28
|
+
accessor authenticated: boolean;
|
|
29
|
+
accessor userLabel: string | undefined;
|
|
30
|
+
accessor pending: boolean;
|
|
31
|
+
render(): lit.TemplateResult<1>;
|
|
32
|
+
}
|
|
33
|
+
declare global {
|
|
34
|
+
interface HTMLElementTagNameMap {
|
|
35
|
+
"wallet-kit-login": WalletKitLoginElement;
|
|
36
|
+
}
|
|
37
|
+
interface HTMLElementEventMap {
|
|
38
|
+
"login-request": CustomEvent<void>;
|
|
39
|
+
"logout-request": CustomEvent<void>;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { WalletKitLoginElement };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
5
|
+
var __typeError = (msg) => {
|
|
6
|
+
throw TypeError(msg);
|
|
7
|
+
};
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
var __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol("metadata")] ?? null)];
|
|
11
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
12
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
13
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
14
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
15
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
16
|
+
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
20
|
+
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
21
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
22
|
+
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
23
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
24
|
+
return __privateGet(this, extra);
|
|
25
|
+
}, set [name](x) {
|
|
26
|
+
return __privateSet(this, extra, x);
|
|
27
|
+
} }, name));
|
|
28
|
+
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
29
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
30
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
31
|
+
if (k) {
|
|
32
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
33
|
+
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
34
|
+
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
35
|
+
}
|
|
36
|
+
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
37
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
38
|
+
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
39
|
+
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
40
|
+
}
|
|
41
|
+
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
42
|
+
};
|
|
43
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
44
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
45
|
+
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
46
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
47
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
48
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
49
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
50
|
+
var _pending_dec, _userLabel_dec, _authenticated_dec, _a, _WalletKitLoginElement_decorators, _init, _authenticated, _userLabel, _pending;
|
|
51
|
+
import { css, html, LitElement, nothing } from "lit";
|
|
52
|
+
import { customElement, property } from "lit/decorators.js";
|
|
53
|
+
_WalletKitLoginElement_decorators = [customElement("wallet-kit-login")];
|
|
54
|
+
class WalletKitLoginElement extends (_a = LitElement, _authenticated_dec = [property({ type: Boolean })], _userLabel_dec = [property({ type: String, attribute: "user-label" })], _pending_dec = [property({ type: Boolean })], _a) {
|
|
55
|
+
constructor() {
|
|
56
|
+
super(...arguments);
|
|
57
|
+
__privateAdd(this, _authenticated, __runInitializers(_init, 8, this, false)), __runInitializers(_init, 11, this);
|
|
58
|
+
__privateAdd(this, _userLabel, __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
|
|
59
|
+
__privateAdd(this, _pending, __runInitializers(_init, 16, this, false)), __runInitializers(_init, 19, this);
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
if (this.pending) {
|
|
63
|
+
return html`<button disabled>Loading…</button>`;
|
|
64
|
+
}
|
|
65
|
+
if (this.authenticated) {
|
|
66
|
+
return html`
|
|
67
|
+
${this.userLabel ? html`<span class="user">signed in as <code>${this.userLabel}</code></span>` : nothing}
|
|
68
|
+
<button
|
|
69
|
+
class="secondary"
|
|
70
|
+
type="button"
|
|
71
|
+
@click=${() => this.dispatchEvent(
|
|
72
|
+
new CustomEvent("logout-request", {
|
|
73
|
+
bubbles: true,
|
|
74
|
+
composed: true
|
|
75
|
+
})
|
|
76
|
+
)}
|
|
77
|
+
>
|
|
78
|
+
Logout
|
|
79
|
+
</button>
|
|
80
|
+
`;
|
|
81
|
+
}
|
|
82
|
+
return html`<button
|
|
83
|
+
type="button"
|
|
84
|
+
@click=${() => this.dispatchEvent(
|
|
85
|
+
new CustomEvent("login-request", { bubbles: true, composed: true })
|
|
86
|
+
)}
|
|
87
|
+
>
|
|
88
|
+
Sign in
|
|
89
|
+
</button>`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
_init = __decoratorStart(_a);
|
|
93
|
+
_authenticated = new WeakMap();
|
|
94
|
+
_userLabel = new WeakMap();
|
|
95
|
+
_pending = new WeakMap();
|
|
96
|
+
__decorateElement(_init, 4, "authenticated", _authenticated_dec, WalletKitLoginElement, _authenticated);
|
|
97
|
+
__decorateElement(_init, 4, "userLabel", _userLabel_dec, WalletKitLoginElement, _userLabel);
|
|
98
|
+
__decorateElement(_init, 4, "pending", _pending_dec, WalletKitLoginElement, _pending);
|
|
99
|
+
WalletKitLoginElement = __decorateElement(_init, 0, "WalletKitLoginElement", _WalletKitLoginElement_decorators, WalletKitLoginElement);
|
|
100
|
+
__publicField(WalletKitLoginElement, "styles", css`
|
|
101
|
+
:host {
|
|
102
|
+
display: inline-flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
gap: 0.75rem;
|
|
105
|
+
font:
|
|
106
|
+
inherit,
|
|
107
|
+
system-ui,
|
|
108
|
+
sans-serif;
|
|
109
|
+
}
|
|
110
|
+
button {
|
|
111
|
+
background: var(--wk-login-bg, #0b5fff);
|
|
112
|
+
color: var(--wk-login-fg, #fff);
|
|
113
|
+
border: 1px solid var(--wk-login-border, transparent);
|
|
114
|
+
border-radius: var(--wk-login-radius, 0.375rem);
|
|
115
|
+
padding: 0.4rem 0.9rem;
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
font: inherit;
|
|
118
|
+
}
|
|
119
|
+
button[disabled] {
|
|
120
|
+
opacity: 0.6;
|
|
121
|
+
cursor: default;
|
|
122
|
+
}
|
|
123
|
+
button.secondary {
|
|
124
|
+
background: transparent;
|
|
125
|
+
color: var(--wk-login-fg-secondary, #111);
|
|
126
|
+
border-color: var(--wk-login-border, #ddd);
|
|
127
|
+
}
|
|
128
|
+
.user {
|
|
129
|
+
font-size: 0.9em;
|
|
130
|
+
color: var(--wk-login-user-fg, inherit);
|
|
131
|
+
}
|
|
132
|
+
code {
|
|
133
|
+
font-size: 0.85em;
|
|
134
|
+
}
|
|
135
|
+
`);
|
|
136
|
+
__runInitializers(_init, 1, WalletKitLoginElement);
|
|
137
|
+
export {
|
|
138
|
+
WalletKitLoginElement
|
|
139
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as lit from 'lit';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import { WalletKitClient } from '@universal-everything/sdk-core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Host element that owns a `WalletKitClient` and exposes it to
|
|
7
|
+
* descendant wallet-kit components via Lit's context protocol.
|
|
8
|
+
*
|
|
9
|
+
* Framework-agnostic: you wire Privy (or whatever identity source) on
|
|
10
|
+
* the host side and pass the resulting client as a property:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const client = new WalletKitClient({
|
|
14
|
+
* baseUrl: RELAYER_BASE,
|
|
15
|
+
* getAccessToken: () => privy.getAccessToken(),
|
|
16
|
+
* });
|
|
17
|
+
* document.querySelector('wallet-kit-provider').client = client;
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* In React 19+ `<wallet-kit-provider client={client}>` Just Works —
|
|
21
|
+
* React maps the prop to the property since the element has a matching
|
|
22
|
+
* reactive property declaration.
|
|
23
|
+
*
|
|
24
|
+
* The provider renders a default slot so it composes like any
|
|
25
|
+
* grouping element — descendants pick the client up via context
|
|
26
|
+
* without extra ceremony.
|
|
27
|
+
*/
|
|
28
|
+
declare class WalletKitProviderElement extends LitElement {
|
|
29
|
+
static styles: lit.CSSResult;
|
|
30
|
+
accessor client: WalletKitClient | undefined;
|
|
31
|
+
render(): lit.TemplateResult<1>;
|
|
32
|
+
}
|
|
33
|
+
declare global {
|
|
34
|
+
interface HTMLElementTagNameMap {
|
|
35
|
+
"wallet-kit-provider": WalletKitProviderElement;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { WalletKitProviderElement };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
5
|
+
var __typeError = (msg) => {
|
|
6
|
+
throw TypeError(msg);
|
|
7
|
+
};
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
var __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol("metadata")] ?? null)];
|
|
11
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
12
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
13
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
14
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
15
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
16
|
+
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
20
|
+
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
21
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
22
|
+
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
23
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
24
|
+
return __privateGet(this, extra);
|
|
25
|
+
}, set [name](x) {
|
|
26
|
+
return __privateSet(this, extra, x);
|
|
27
|
+
} }, name));
|
|
28
|
+
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
29
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
30
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
31
|
+
if (k) {
|
|
32
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
33
|
+
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
34
|
+
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
35
|
+
}
|
|
36
|
+
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
37
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
38
|
+
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
39
|
+
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
40
|
+
}
|
|
41
|
+
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
42
|
+
};
|
|
43
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
44
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
45
|
+
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
46
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
47
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
48
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
49
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
50
|
+
var _client_dec, _a, _WalletKitProviderElement_decorators, _init, _client;
|
|
51
|
+
import { provide } from "@lit/context";
|
|
52
|
+
import { css, html, LitElement } from "lit";
|
|
53
|
+
import { customElement, property } from "lit/decorators.js";
|
|
54
|
+
import { walletKitContext } from "./context";
|
|
55
|
+
_WalletKitProviderElement_decorators = [customElement("wallet-kit-provider")];
|
|
56
|
+
class WalletKitProviderElement extends (_a = LitElement, _client_dec = [provide({ context: walletKitContext }), property({ attribute: false })], _a) {
|
|
57
|
+
constructor() {
|
|
58
|
+
super(...arguments);
|
|
59
|
+
__privateAdd(this, _client, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
return html`<slot></slot>`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
_init = __decoratorStart(_a);
|
|
66
|
+
_client = new WeakMap();
|
|
67
|
+
__decorateElement(_init, 4, "client", _client_dec, WalletKitProviderElement, _client);
|
|
68
|
+
WalletKitProviderElement = __decorateElement(_init, 0, "WalletKitProviderElement", _WalletKitProviderElement_decorators, WalletKitProviderElement);
|
|
69
|
+
__publicField(WalletKitProviderElement, "styles", css`
|
|
70
|
+
:host {
|
|
71
|
+
display: contents;
|
|
72
|
+
}
|
|
73
|
+
`);
|
|
74
|
+
__runInitializers(_init, 1, WalletKitProviderElement);
|
|
75
|
+
export {
|
|
76
|
+
WalletKitProviderElement
|
|
77
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as lit from 'lit';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import { Wallet } from '@universal-everything/sdk-core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Renders the authenticated user's wallets by calling
|
|
7
|
+
* `client.listWallets()` off the `WalletKitClient` that an ancestor
|
|
8
|
+
* `<wallet-kit-provider>` placed in context.
|
|
9
|
+
*
|
|
10
|
+
* Use it as a drop-in anywhere inside a provider:
|
|
11
|
+
*
|
|
12
|
+
* ```html
|
|
13
|
+
* <wallet-kit-provider .client=${client}>
|
|
14
|
+
* <wallet-kit-wallet-list></wallet-kit-wallet-list>
|
|
15
|
+
* </wallet-kit-provider>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Auto-loads on first connect; `refresh()` re-fetches. Emits
|
|
19
|
+
* `wallet-select` with `{ wallet: Wallet }` when the user clicks a
|
|
20
|
+
* row — hosts can react to selection without pulling the full list
|
|
21
|
+
* back out of the component.
|
|
22
|
+
*
|
|
23
|
+
* Loading / error / empty states are all rendered inline via
|
|
24
|
+
* dedicated slots so hosts can theme them without re-implementing
|
|
25
|
+
* the happy path:
|
|
26
|
+
*
|
|
27
|
+
* ```html
|
|
28
|
+
* <wallet-kit-wallet-list>
|
|
29
|
+
* <span slot="empty">No wallets yet — create one above.</span>
|
|
30
|
+
* </wallet-kit-wallet-list>
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
declare class WalletKitWalletListElement extends LitElement {
|
|
34
|
+
static styles: lit.CSSResult;
|
|
35
|
+
private accessor client;
|
|
36
|
+
private accessor wallets;
|
|
37
|
+
private accessor error;
|
|
38
|
+
private accessor loading;
|
|
39
|
+
/**
|
|
40
|
+
* When set, the matching wallet row renders with `aria-selected`.
|
|
41
|
+
* Purely visual — selection is entirely in the host's control, the
|
|
42
|
+
* component never owns selection state.
|
|
43
|
+
*/
|
|
44
|
+
accessor selectedWalletId: string | undefined;
|
|
45
|
+
private hasLoadedOnce;
|
|
46
|
+
willUpdate(changed: Map<string, unknown>): void;
|
|
47
|
+
refresh(): Promise<void>;
|
|
48
|
+
private selectWallet;
|
|
49
|
+
render(): lit.TemplateResult<1>;
|
|
50
|
+
}
|
|
51
|
+
declare global {
|
|
52
|
+
interface HTMLElementTagNameMap {
|
|
53
|
+
"wallet-kit-wallet-list": WalletKitWalletListElement;
|
|
54
|
+
}
|
|
55
|
+
interface HTMLElementEventMap {
|
|
56
|
+
"wallet-select": CustomEvent<{
|
|
57
|
+
wallet: Wallet;
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { WalletKitWalletListElement };
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
5
|
+
var __typeError = (msg) => {
|
|
6
|
+
throw TypeError(msg);
|
|
7
|
+
};
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
var __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol("metadata")] ?? null)];
|
|
11
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
12
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
13
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
14
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
15
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
16
|
+
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
20
|
+
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
21
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
22
|
+
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
23
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
24
|
+
return __privateGet(this, extra);
|
|
25
|
+
}, set [name](x) {
|
|
26
|
+
return __privateSet(this, extra, x);
|
|
27
|
+
} }, name));
|
|
28
|
+
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
29
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
30
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
31
|
+
if (k) {
|
|
32
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
33
|
+
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
34
|
+
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
35
|
+
}
|
|
36
|
+
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
37
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
38
|
+
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
39
|
+
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
40
|
+
}
|
|
41
|
+
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
42
|
+
};
|
|
43
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
44
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
45
|
+
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
46
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
47
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
48
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
49
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
50
|
+
var _selectedWalletId_dec, _loading_dec, _error_dec, _wallets_dec, _client_dec, _a, _WalletKitWalletListElement_decorators, _init, _client, _wallets, _error, _loading, _selectedWalletId;
|
|
51
|
+
import { consume } from "@lit/context";
|
|
52
|
+
import { css, html, LitElement, nothing } from "lit";
|
|
53
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
54
|
+
import { walletKitContext } from "./context";
|
|
55
|
+
_WalletKitWalletListElement_decorators = [customElement("wallet-kit-wallet-list")];
|
|
56
|
+
class WalletKitWalletListElement extends (_a = LitElement, _client_dec = [consume({ context: walletKitContext, subscribe: true }), state()], _wallets_dec = [state()], _error_dec = [state()], _loading_dec = [state()], _selectedWalletId_dec = [property({ type: String, attribute: "selected-wallet-id" })], _a) {
|
|
57
|
+
constructor() {
|
|
58
|
+
super(...arguments);
|
|
59
|
+
__privateAdd(this, _client, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
|
|
60
|
+
__privateAdd(this, _wallets, __runInitializers(_init, 12, this, null)), __runInitializers(_init, 15, this);
|
|
61
|
+
__privateAdd(this, _error, __runInitializers(_init, 16, this, null)), __runInitializers(_init, 19, this);
|
|
62
|
+
__privateAdd(this, _loading, __runInitializers(_init, 20, this, false)), __runInitializers(_init, 23, this);
|
|
63
|
+
__privateAdd(this, _selectedWalletId, __runInitializers(_init, 24, this)), __runInitializers(_init, 27, this);
|
|
64
|
+
__publicField(this, "hasLoadedOnce", false);
|
|
65
|
+
}
|
|
66
|
+
willUpdate(changed) {
|
|
67
|
+
if (changed.has("client") && this.client && !this.hasLoadedOnce) {
|
|
68
|
+
this.hasLoadedOnce = true;
|
|
69
|
+
void this.refresh();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async refresh() {
|
|
73
|
+
if (!this.client) return;
|
|
74
|
+
this.loading = true;
|
|
75
|
+
this.error = null;
|
|
76
|
+
try {
|
|
77
|
+
this.wallets = await this.client.listWallets();
|
|
78
|
+
} catch (err) {
|
|
79
|
+
this.error = err;
|
|
80
|
+
} finally {
|
|
81
|
+
this.loading = false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
selectWallet(wallet) {
|
|
85
|
+
this.dispatchEvent(
|
|
86
|
+
new CustomEvent("wallet-select", {
|
|
87
|
+
detail: { wallet },
|
|
88
|
+
bubbles: true,
|
|
89
|
+
composed: true
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
render() {
|
|
94
|
+
if (!this.client) {
|
|
95
|
+
return html`<div class="hint">No client. Wrap in <wallet-kit-provider>.</div>`;
|
|
96
|
+
}
|
|
97
|
+
if (this.loading && !this.wallets) {
|
|
98
|
+
return html`<slot name="loading"><div class="hint">Loading wallets…</div></slot>`;
|
|
99
|
+
}
|
|
100
|
+
if (this.error) {
|
|
101
|
+
return html`<div class="error">
|
|
102
|
+
<slot name="error">${this.error.code || this.error.message}</slot>
|
|
103
|
+
</div>`;
|
|
104
|
+
}
|
|
105
|
+
if (!this.wallets || this.wallets.length === 0) {
|
|
106
|
+
return html`<slot name="empty"><div class="hint">No wallets yet.</div></slot>`;
|
|
107
|
+
}
|
|
108
|
+
return html`
|
|
109
|
+
<ul role="listbox">
|
|
110
|
+
${this.wallets.map(
|
|
111
|
+
(w) => html`
|
|
112
|
+
<li
|
|
113
|
+
class=${w.isPrimary ? "primary" : ""}
|
|
114
|
+
role="option"
|
|
115
|
+
aria-selected=${w.walletId === this.selectedWalletId ? "true" : "false"}
|
|
116
|
+
tabindex="0"
|
|
117
|
+
@click=${() => this.selectWallet(w)}
|
|
118
|
+
@keydown=${(e) => {
|
|
119
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
this.selectWallet(w);
|
|
122
|
+
}
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
<span class="label">
|
|
126
|
+
${w.label || html`<code>${w.address}</code>`}
|
|
127
|
+
${w.isPrimary ? html`<span class="meta">(primary)</span>` : nothing}
|
|
128
|
+
</span>
|
|
129
|
+
<span class="meta">
|
|
130
|
+
${w.label ? html`<code>${shorten(w.address)}</code>` : nothing}
|
|
131
|
+
</span>
|
|
132
|
+
</li>
|
|
133
|
+
`
|
|
134
|
+
)}
|
|
135
|
+
</ul>
|
|
136
|
+
`;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
_init = __decoratorStart(_a);
|
|
140
|
+
_client = new WeakMap();
|
|
141
|
+
_wallets = new WeakMap();
|
|
142
|
+
_error = new WeakMap();
|
|
143
|
+
_loading = new WeakMap();
|
|
144
|
+
_selectedWalletId = new WeakMap();
|
|
145
|
+
__decorateElement(_init, 4, "client", _client_dec, WalletKitWalletListElement, _client);
|
|
146
|
+
__decorateElement(_init, 4, "wallets", _wallets_dec, WalletKitWalletListElement, _wallets);
|
|
147
|
+
__decorateElement(_init, 4, "error", _error_dec, WalletKitWalletListElement, _error);
|
|
148
|
+
__decorateElement(_init, 4, "loading", _loading_dec, WalletKitWalletListElement, _loading);
|
|
149
|
+
__decorateElement(_init, 4, "selectedWalletId", _selectedWalletId_dec, WalletKitWalletListElement, _selectedWalletId);
|
|
150
|
+
WalletKitWalletListElement = __decorateElement(_init, 0, "WalletKitWalletListElement", _WalletKitWalletListElement_decorators, WalletKitWalletListElement);
|
|
151
|
+
__publicField(WalletKitWalletListElement, "styles", css`
|
|
152
|
+
:host {
|
|
153
|
+
display: block;
|
|
154
|
+
font: inherit;
|
|
155
|
+
}
|
|
156
|
+
ul {
|
|
157
|
+
list-style: none;
|
|
158
|
+
padding: 0;
|
|
159
|
+
margin: 0;
|
|
160
|
+
display: flex;
|
|
161
|
+
flex-direction: column;
|
|
162
|
+
gap: 0.25rem;
|
|
163
|
+
}
|
|
164
|
+
li {
|
|
165
|
+
padding: 0.5rem 0.75rem;
|
|
166
|
+
border: 1px solid var(--wk-list-border, #e5e5e5);
|
|
167
|
+
border-radius: var(--wk-list-radius, 0.375rem);
|
|
168
|
+
background: var(--wk-list-bg, #fff);
|
|
169
|
+
cursor: pointer;
|
|
170
|
+
display: flex;
|
|
171
|
+
align-items: center;
|
|
172
|
+
justify-content: space-between;
|
|
173
|
+
gap: 0.5rem;
|
|
174
|
+
}
|
|
175
|
+
li.primary {
|
|
176
|
+
border-color: var(--wk-list-primary-border, #0b5fff);
|
|
177
|
+
}
|
|
178
|
+
li[aria-selected="true"] {
|
|
179
|
+
background: var(--wk-list-selected-bg, #e8f0ff);
|
|
180
|
+
}
|
|
181
|
+
code {
|
|
182
|
+
font-size: 0.85em;
|
|
183
|
+
}
|
|
184
|
+
.label {
|
|
185
|
+
font-weight: 500;
|
|
186
|
+
}
|
|
187
|
+
.meta {
|
|
188
|
+
font-size: 0.75em;
|
|
189
|
+
color: var(--wk-list-meta-fg, #666);
|
|
190
|
+
display: flex;
|
|
191
|
+
gap: 0.25rem;
|
|
192
|
+
}
|
|
193
|
+
.error {
|
|
194
|
+
color: var(--wk-list-error-fg, #b00);
|
|
195
|
+
padding: 0.5rem 0.75rem;
|
|
196
|
+
border: 1px solid var(--wk-list-error-border, #fbb);
|
|
197
|
+
border-radius: var(--wk-list-radius, 0.375rem);
|
|
198
|
+
background: var(--wk-list-error-bg, #fff5f5);
|
|
199
|
+
}
|
|
200
|
+
.hint {
|
|
201
|
+
color: var(--wk-list-meta-fg, #666);
|
|
202
|
+
padding: 0.5rem 0.75rem;
|
|
203
|
+
}
|
|
204
|
+
`);
|
|
205
|
+
__runInitializers(_init, 1, WalletKitWalletListElement);
|
|
206
|
+
function shorten(addr) {
|
|
207
|
+
return addr.length <= 12 ? addr : `${addr.slice(0, 6)}\u2026${addr.slice(-4)}`;
|
|
208
|
+
}
|
|
209
|
+
export {
|
|
210
|
+
WalletKitWalletListElement
|
|
211
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@universal-everything/ui",
|
|
3
|
+
"version": "1.0.0-dev.50f8f9d",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/universal-everything/universal-relayer.git",
|
|
7
|
+
"directory": "packages/ui"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./wallet-kit-provider": {
|
|
18
|
+
"types": "./dist/wallet-kit-provider.d.ts",
|
|
19
|
+
"import": "./dist/wallet-kit-provider.js"
|
|
20
|
+
},
|
|
21
|
+
"./wallet-kit-login": {
|
|
22
|
+
"types": "./dist/wallet-kit-login.d.ts",
|
|
23
|
+
"import": "./dist/wallet-kit-login.js"
|
|
24
|
+
},
|
|
25
|
+
"./wallet-kit-wallet-list": {
|
|
26
|
+
"types": "./dist/wallet-kit-wallet-list.d.ts",
|
|
27
|
+
"import": "./dist/wallet-kit-wallet-list.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@lit/context": "^1.1.0",
|
|
38
|
+
"lit": "^3.2.0",
|
|
39
|
+
"@universal-everything/sdk-core": "1.1.0-dev.50f8f9d"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"jsdom": "^30.0.1",
|
|
43
|
+
"tsup": "^8.5.0",
|
|
44
|
+
"typescript": "^5.7.0",
|
|
45
|
+
"vitest": "^2.1.9"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsup",
|
|
49
|
+
"typecheck": "tsc --noEmit",
|
|
50
|
+
"test": "vitest run"
|
|
51
|
+
}
|
|
52
|
+
}
|