@meshsdk/react 1.1.1 → 1.1.3

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.
Files changed (18) hide show
  1. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/CardanoWallet.d.ts +4 -1
  2. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/CardanoWallet.jsx +12 -7
  3. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/CardanoWallet.jsx.map +1 -1
  4. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/WalletBalance.d.ts +2 -1
  5. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/WalletBalance.jsx +4 -4
  6. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/WalletBalance.jsx.map +1 -1
  7. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MenuItem/MenuItem.jsx +1 -1
  8. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MenuItem/MenuItem.jsx.map +1 -1
  9. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/tsconfig.tsbuildinfo +1 -1
  10. package/README.md +0 -18
  11. package/dist/components/CardanoWallet/CardanoWallet.d.ts +4 -1
  12. package/dist/components/CardanoWallet/WalletBalance.d.ts +2 -1
  13. package/dist/react.cjs +12 -12
  14. package/dist/react.js +216 -206
  15. package/package.json +2 -2
  16. package/src/components/CardanoWallet/CardanoWallet.tsx +32 -15
  17. package/src/components/CardanoWallet/WalletBalance.tsx +4 -4
  18. package/src/components/MenuItem/MenuItem.tsx +1 -1
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "React Hooks & Components you need for building dApps on Cardano.",
4
4
  "homepage": "https://meshjs.dev",
5
5
  "author": "MeshJS",
6
- "version": "1.1.1",
6
+ "version": "1.1.3",
7
7
  "license": "Apache-2.0",
8
8
  "type": "module",
9
9
  "repository": {
@@ -61,7 +61,7 @@
61
61
  "vite": "3.1.4"
62
62
  },
63
63
  "peerDependencies": {
64
- "@meshsdk/core": "1.2.0-beta.4",
64
+ "@meshsdk/core": "1.3.0",
65
65
  "react-dom": "17.x || 18.x",
66
66
  "react": "17.x || 18.x"
67
67
  },
@@ -1,5 +1,5 @@
1
1
  import tw, { styled } from 'twin.macro';
2
- import { useState } from 'react';
2
+ import { useEffect, useState } from 'react';
3
3
  import { useWallet, useWalletList } from '@mesh/hooks';
4
4
  import { MenuItem } from '../MenuItem';
5
5
  import { WalletBalance } from './WalletBalance';
@@ -22,13 +22,25 @@ const StyledMenuList = styled.div(({ hidden }: { hidden: boolean }) => [
22
22
  hidden && tw`hidden`,
23
23
  ]);
24
24
 
25
- export const CardanoWallet = () => {
25
+ export const CardanoWallet = ({
26
+ label = 'Connect Wallet',
27
+ onConnected = undefined
28
+ }: {
29
+ label?: string,
30
+ onConnected?: Function
31
+ }) => {
26
32
  const wallets = useWalletList();
27
33
 
28
34
  const [hideMenuList, setHideMenuList] = useState(true);
29
35
 
30
36
  const { connect, connecting, connected, disconnect, name } = useWallet();
31
37
 
38
+ useEffect(() => {
39
+ if (connected && onConnected) {
40
+ onConnected();
41
+ }
42
+ }, [connected]);
43
+
32
44
  return (
33
45
  <div
34
46
  style={{ width: 'fit-content' }}
@@ -37,15 +49,20 @@ export const CardanoWallet = () => {
37
49
  >
38
50
  <StyledMenuButton
39
51
  type="button"
52
+ className="mr-wallet-button"
40
53
  onClick={() => setHideMenuList(!hideMenuList)}
41
54
  >
42
55
  <WalletBalance
43
56
  name={name}
44
57
  connected={connected}
45
58
  connecting={connecting}
59
+ label={label}
46
60
  />
47
61
  </StyledMenuButton>
48
- <StyledMenuList hidden={hideMenuList}>
62
+ <StyledMenuList
63
+ hidden={hideMenuList}
64
+ className="mr-menu-list"
65
+ >
49
66
  {!connected && wallets.length > 0 ? (
50
67
  wallets.map((wallet, index) => (
51
68
  <MenuItem
@@ -59,18 +76,18 @@ export const CardanoWallet = () => {
59
76
  active={name === wallet.name}
60
77
  />
61
78
  ))
62
- ) : wallets.length === 0 ? (
63
- <span>No Wallet Found</span>
64
- ) : (
65
- <>
66
- <MenuItem
67
- active={false}
68
- label="disconnect"
69
- action={disconnect}
70
- icon={undefined}
71
- />
72
- </>
73
- )}
79
+ ) : wallets.length === 0 ? (
80
+ <span>No Wallet Found</span>
81
+ ) : (
82
+ <>
83
+ <MenuItem
84
+ active={false}
85
+ label="disconnect"
86
+ action={disconnect}
87
+ icon={undefined}
88
+ />
89
+ </>
90
+ )}
74
91
  </StyledMenuList>
75
92
  </div>
76
93
  );
@@ -10,14 +10,14 @@ const StyledSmall = tw.span`
10
10
  text-xs
11
11
  `;
12
12
 
13
- export const WalletBalance = ({ connected, name, connecting }) => {
13
+ export const WalletBalance = ({ connected, name, connecting, label }) => {
14
14
  const wallet = useWalletList().find((wallet) => wallet.name === name);
15
15
  const balance = useLovelace();
16
16
 
17
17
  return connected && balance && wallet?.icon ? (
18
18
  <>
19
- <StyledIcon src={wallet.icon} />
20
- {parseInt((parseInt(balance, 10) / 1_000_000).toString(), 10)}.
19
+ <StyledIcon src={wallet.icon} />₳{' '}
20
+ {parseInt((parseInt(balance, 10) / 1_000_000).toString(), 10)}.
21
21
  <StyledSmall>{balance.substr(balance.length - 6)}</StyledSmall>
22
22
  </>
23
23
  ) : connected && wallet?.icon ? (
@@ -28,7 +28,7 @@ export const WalletBalance = ({ connected, name, connecting }) => {
28
28
  <>Connecting...</>
29
29
  ) : (
30
30
  <>
31
- Connect Wallet <ChevronDown />
31
+ {label} <ChevronDown />
32
32
  </>
33
33
  );
34
34
  };
@@ -24,7 +24,7 @@ const StyledActive = tw.span`
24
24
  export const MenuItem = ({ icon, label, action, active }) => (
25
25
  <StyledItem onClick={action}>
26
26
  {icon && <StyledIcon src={icon} />}
27
- <StyledName>
27
+ <StyledName className='mr-menu-item'>
28
28
  {label
29
29
  .split(' ')
30
30
  .map((word: string) => {