@gluwa/connect-kit 0.1.0-next.0 → 0.1.0-next.2

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.
@@ -1,8 +1,9 @@
1
1
  import { type FC, useMemo } from 'react';
2
- import { QRCodeSVG } from 'qrcode.react';
3
2
  import { isMobileDevice, tryOpenDeepLink } from '../utils/platform';
4
3
  import { type WCWallet, type WCSubView } from '../types';
5
4
  import deeplink from '../../assets/deeplink.png';
5
+ import { QRFrame, CopyLinkButton } from '../components/QRFrame';
6
+ import { CONNECTOR_META } from '../connector-meta';
6
7
 
7
8
  interface WalletConnectViewProps {
8
9
  subView: WCSubView;
@@ -30,42 +31,11 @@ export const WalletConnectView: FC<WalletConnectViewProps> = (props) => {
30
31
 
31
32
  const WCQRView: FC<WalletConnectViewProps> = ({ qrUri, logoUrl, walletList, onShowList }) => (
32
33
  <div className="ck-view ck-view--qr">
33
- <div className={`ck-qr-frame ${!qrUri ? 'ck-qr-frame--loading' : ''}`}>
34
- {qrUri ? (
35
- <QRCodeSVG
36
- value={qrUri}
37
- size={196}
38
- level="H"
39
- imageSettings={
40
- logoUrl
41
- ? {
42
- src: logoUrl,
43
- width: 40,
44
- height: 40,
45
- excavate: true,
46
- }
47
- : undefined
48
- }
49
- />
50
- ) : (
51
- <div className="ck-qr-spinner" aria-label="Loading QR code" />
52
- )}
53
- </div>
34
+ <QRFrame qrUri={qrUri} logoUrl={logoUrl} />
54
35
 
55
36
  <p className="ck-view__caption">Scan this QR Code with your phone</p>
56
37
 
57
- {qrUri && (
58
- <button
59
- type="button"
60
- className="ck-copy-link"
61
- onClick={() => {
62
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
63
- navigator.clipboard.writeText(qrUri);
64
- }}
65
- >
66
- Copy link
67
- </button>
68
- )}
38
+ <CopyLinkButton qrUri={qrUri} />
69
39
 
70
40
  <button type="button" className="ck-all-wallets-btn" onClick={onShowList}>
71
41
  <span className="ck-all-wallets-btn__icon" aria-hidden="true" />
@@ -77,7 +47,7 @@ const WCQRView: FC<WalletConnectViewProps> = ({ qrUri, logoUrl, walletList, onSh
77
47
  </div>
78
48
  );
79
49
 
80
- const CREDIT_WALLET_NAME = 'Credit Wallet';
50
+ const CREDIT_WALLET_NAME = CONNECTOR_META.CREDIT_WALLET.label;
81
51
 
82
52
  const WalletListView: FC<WalletConnectViewProps> = ({
83
53
  walletList,
@@ -90,7 +60,7 @@ const WalletListView: FC<WalletConnectViewProps> = ({
90
60
  onSearchChange,
91
61
  onFilterToggle,
92
62
  }) => {
93
- const isMobile = isMobileDevice();
63
+ const isMobile = useMemo(() => isMobileDevice(), []);
94
64
 
95
65
  const filtered = useMemo(() => {
96
66
  const q = walletListSearch.trim().toLowerCase();
@@ -111,11 +81,10 @@ const WalletListView: FC<WalletConnectViewProps> = ({
111
81
  }, [walletList, walletListSearch, walletListFilterActive]);
112
82
 
113
83
  const handleClickWallet = (wallet: WCWallet): void => {
114
- const uri = qrUri;
115
- if (isMobile && uri) {
84
+ if (isMobile && qrUri) {
116
85
  const target = wallet.mobileNative || wallet.mobileUniversal;
117
86
  if (target) {
118
- tryOpenDeepLink(uri, target);
87
+ tryOpenDeepLink(qrUri, target);
119
88
  return;
120
89
  }
121
90
  }
@@ -211,40 +180,11 @@ const WalletQRView: FC<{ wallet: WCWallet; qrUri: string | null }> = ({ wallet,
211
180
 
212
181
  return (
213
182
  <div className="ck-view ck-view--qr">
214
- <div className={`ck-qr-frame ${!qrUri ? 'ck-qr-frame--loading' : ''}`}>
215
- {qrUri ? (
216
- <QRCodeSVG
217
- value={qrUri}
218
- size={196}
219
- level="H"
220
- {...(logoSrc && {
221
- imageSettings: {
222
- src: logoSrc,
223
- width: 40,
224
- height: 40,
225
- excavate: true,
226
- },
227
- })}
228
- />
229
- ) : (
230
- <div className="ck-qr-spinner" aria-label="Loading QR code" />
231
- )}
232
- </div>
183
+ <QRFrame qrUri={qrUri} logoUrl={logoSrc} />
233
184
 
234
185
  <p className="ck-view__caption">Scan this QR Code with your phone</p>
235
186
 
236
- {qrUri && (
237
- <button
238
- type="button"
239
- className="ck-copy-link"
240
- onClick={() => {
241
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
242
- navigator.clipboard.writeText(qrUri);
243
- }}
244
- >
245
- Copy link
246
- </button>
247
- )}
187
+ <CopyLinkButton qrUri={qrUri} />
248
188
 
249
189
  {downloadUrl && (
250
190
  <div className="ck-download-card">
package/tsup.config.ts CHANGED
@@ -7,7 +7,18 @@ export default defineConfig({
7
7
  dts: true,
8
8
  clean: true,
9
9
  target: 'es2019',
10
- external: ['react', 'react-native'],
10
+ external: [
11
+ 'react',
12
+ 'react-native',
13
+ 'wagmi',
14
+ '@wagmi/core',
15
+ 'viem',
16
+ '@gluwa/credit-connect-sdk',
17
+ '@gluwa/credit-connect-sdk/dapp',
18
+ '@gluwa/credit-connect-sdk/storage',
19
+ '@gluwa/credit-connect-sdk/e2ee',
20
+ '@gluwa/credit-connect-sdk/hub',
21
+ ],
11
22
  banner: {
12
23
  js: 'import React from "react";',
13
24
  },