@tronweb3/tronwallet-adapter-react-ui 1.0.1 → 1.1.1

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 (83) hide show
  1. package/lib/cjs/Button.js +55 -0
  2. package/lib/cjs/Button.js.map +1 -0
  3. package/lib/cjs/Collapse.js +61 -0
  4. package/lib/cjs/Collapse.js.map +1 -0
  5. package/lib/cjs/Modal/ReactPortal.js +38 -0
  6. package/lib/cjs/Modal/ReactPortal.js.map +1 -0
  7. package/lib/cjs/Modal/WalletSelectModal.js +81 -0
  8. package/lib/cjs/Modal/WalletSelectModal.js.map +1 -0
  9. package/lib/cjs/WalletActionButton.js +122 -0
  10. package/lib/cjs/WalletActionButton.js.map +1 -0
  11. package/lib/cjs/WalletConnectButton.js +75 -0
  12. package/lib/cjs/WalletConnectButton.js.map +1 -0
  13. package/lib/cjs/WalletDisconnectButton.js +63 -0
  14. package/lib/cjs/WalletDisconnectButton.js.map +1 -0
  15. package/lib/cjs/WalletItem.js +17 -0
  16. package/lib/cjs/WalletItem.js.map +1 -0
  17. package/lib/cjs/WalletModalProvider.js +52 -0
  18. package/lib/cjs/WalletModalProvider.js.map +1 -0
  19. package/lib/cjs/WalletSelectButton.js +53 -0
  20. package/lib/cjs/WalletSelectButton.js.map +1 -0
  21. package/lib/cjs/index.js +27 -0
  22. package/lib/cjs/index.js.map +1 -0
  23. package/lib/cjs/package.json +1 -0
  24. package/lib/cjs/useWalletModal.js +26 -0
  25. package/lib/cjs/useWalletModal.js.map +1 -0
  26. package/lib/cjs/utils.js +16 -0
  27. package/lib/cjs/utils.js.map +1 -0
  28. package/lib/esm/Button.js +15 -0
  29. package/lib/esm/Button.js.map +1 -0
  30. package/lib/esm/Collapse.js +40 -0
  31. package/lib/esm/Collapse.js.map +1 -0
  32. package/lib/esm/Modal/ReactPortal.js +34 -0
  33. package/lib/esm/Modal/ReactPortal.js.map +1 -0
  34. package/lib/esm/Modal/WalletSelectModal.js +54 -0
  35. package/lib/esm/Modal/WalletSelectModal.js.map +1 -0
  36. package/lib/esm/WalletActionButton.js +72 -0
  37. package/lib/esm/WalletActionButton.js.map +1 -0
  38. package/lib/esm/WalletConnectButton.js +27 -0
  39. package/lib/esm/WalletConnectButton.js.map +1 -0
  40. package/lib/esm/WalletDisconnectButton.js +24 -0
  41. package/lib/esm/WalletDisconnectButton.js.map +1 -0
  42. package/lib/esm/WalletItem.js +10 -0
  43. package/lib/esm/WalletItem.js.map +1 -0
  44. package/lib/esm/WalletModalProvider.js +13 -0
  45. package/lib/esm/WalletModalProvider.js.map +1 -0
  46. package/lib/esm/WalletSelectButton.js +14 -0
  47. package/lib/esm/WalletSelectButton.js.map +1 -0
  48. package/lib/esm/index.js +11 -0
  49. package/lib/esm/index.js.map +1 -0
  50. package/lib/esm/useWalletModal.js +22 -0
  51. package/lib/esm/useWalletModal.js.map +1 -0
  52. package/lib/esm/utils.js +12 -0
  53. package/lib/esm/utils.js.map +1 -0
  54. package/lib/types/Button.d.ts +11 -0
  55. package/lib/types/Button.d.ts.map +1 -0
  56. package/lib/types/Collapse.d.ts +11 -0
  57. package/lib/types/Collapse.d.ts.map +1 -0
  58. package/lib/types/Modal/ReactPortal.d.ts +7 -0
  59. package/lib/types/Modal/ReactPortal.d.ts.map +1 -0
  60. package/lib/types/Modal/WalletSelectModal.d.ts +8 -0
  61. package/lib/types/Modal/WalletSelectModal.d.ts.map +1 -0
  62. package/lib/types/WalletActionButton.d.ts +4 -0
  63. package/lib/types/WalletActionButton.d.ts.map +1 -0
  64. package/lib/types/WalletConnectButton.d.ts +4 -0
  65. package/lib/types/WalletConnectButton.d.ts.map +1 -0
  66. package/lib/types/WalletDisconnectButton.d.ts +4 -0
  67. package/lib/types/WalletDisconnectButton.d.ts.map +1 -0
  68. package/lib/types/WalletItem.d.ts +8 -0
  69. package/lib/types/WalletItem.d.ts.map +1 -0
  70. package/lib/types/WalletModalProvider.d.ts +3 -0
  71. package/lib/types/WalletModalProvider.d.ts.map +1 -0
  72. package/lib/types/WalletSelectButton.d.ts +4 -0
  73. package/lib/types/WalletSelectButton.d.ts.map +1 -0
  74. package/lib/types/index.d.ts +11 -0
  75. package/lib/types/index.d.ts.map +1 -0
  76. package/lib/types/useWalletModal.d.ts +8 -0
  77. package/lib/types/useWalletModal.d.ts.map +1 -0
  78. package/lib/types/utils.d.ts +2 -0
  79. package/lib/types/utils.d.ts.map +1 -0
  80. package/package.json +68 -63
  81. package/src/Collapse.tsx +6 -0
  82. package/src/WalletActionButton.tsx +34 -16
  83. package/style.css +5 -3
@@ -0,0 +1,8 @@
1
+ import type { FC, PropsWithChildren } from 'react';
2
+ type ModalProps = PropsWithChildren<{
3
+ visible: boolean;
4
+ onClose: () => void;
5
+ }>;
6
+ export declare const WalletSelectModal: FC<ModalProps>;
7
+ export {};
8
+ //# sourceMappingURL=WalletSelectModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletSelectModal.d.ts","sourceRoot":"","sources":["../../../src/Modal/WalletSelectModal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAKnD,KAAK,UAAU,GAAG,iBAAiB,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC,CAAC;AACH,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,UAAU,CA+E5C,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FC } from 'react';
2
+ import type { ButtonProps } from './Button.js';
3
+ export declare const WalletActionButton: FC<ButtonProps>;
4
+ //# sourceMappingURL=WalletActionButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletActionButton.d.ts","sourceRoot":"","sources":["../../src/WalletActionButton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO/C,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,WAAW,CAyG9C,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FC } from 'react';
2
+ import type { ButtonProps } from './Button.js';
3
+ export declare const WalletConnectButton: FC<ButtonProps>;
4
+ //# sourceMappingURL=WalletConnectButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletConnectButton.d.ts","sourceRoot":"","sources":["../../src/WalletConnectButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAc,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,WAAW,CAkC/C,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { FC } from 'react';
2
+ import type { ButtonProps } from './Button.js';
3
+ export declare const WalletDisconnectButton: FC<ButtonProps>;
4
+ //# sourceMappingURL=WalletDisconnectButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletDisconnectButton.d.ts","sourceRoot":"","sources":["../../src/WalletDisconnectButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAqB,MAAM,OAAO,CAAC;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,WAAW,CA8BlD,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Wallet } from '@tronweb3/tronwallet-adapter-react-hooks';
2
+ import type { FC } from 'react';
3
+ export interface WalletItemProps {
4
+ onClick: () => void;
5
+ wallet: Wallet;
6
+ }
7
+ export declare const WalletItem: FC<WalletItemProps>;
8
+ //# sourceMappingURL=WalletItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletItem.d.ts","sourceRoot":"","sources":["../../src/WalletItem.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AACvE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIhC,MAAM,WAAW,eAAe;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAS1C,CAAC"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare function WalletModalProvider({ children, ...props }: any): JSX.Element;
3
+ //# sourceMappingURL=WalletModalProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletModalProvider.d.ts","sourceRoot":"","sources":["../../src/WalletModalProvider.tsx"],"names":[],"mappings":";AAIA,wBAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,eAa9D"}
@@ -0,0 +1,4 @@
1
+ import type { FC } from 'react';
2
+ import type { ButtonProps } from './Button.js';
3
+ export declare const WalletSelectButton: FC<ButtonProps>;
4
+ //# sourceMappingURL=WalletSelectButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletSelectButton.d.ts","sourceRoot":"","sources":["../../src/WalletSelectButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,EAAE,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,WAAW,CAgB9C,CAAC"}
@@ -0,0 +1,11 @@
1
+ export * from './Collapse.js';
2
+ export * from './Button.js';
3
+ export * from './Modal/WalletSelectModal.js';
4
+ export * from './WalletConnectButton.js';
5
+ export * from './WalletDisconnectButton.js';
6
+ export * from './WalletItem.js';
7
+ export * from './WalletActionButton.js';
8
+ export * from './WalletSelectButton.js';
9
+ export * from './useWalletModal.js';
10
+ export * from './WalletModalProvider.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export interface WalletModalContextProps {
3
+ visible: boolean;
4
+ setVisible: (open: boolean) => void;
5
+ }
6
+ export declare const WalletModalContext: import("react").Context<WalletModalContextProps>;
7
+ export declare function useWalletModal(): WalletModalContextProps;
8
+ //# sourceMappingURL=useWalletModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWalletModal.d.ts","sourceRoot":"","sources":["../../src/useWalletModal.tsx"],"names":[],"mappings":";AAEA,MAAM,WAAW,uBAAuB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC;AAoBD,eAAO,MAAM,kBAAkB,kDAA+D,CAAC;AAE/F,wBAAgB,cAAc,IAAI,uBAAuB,CAExD"}
@@ -0,0 +1,2 @@
1
+ export declare function copyData(copyText: string): void;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.tsx"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,QAUxC"}
package/package.json CHANGED
@@ -1,65 +1,70 @@
1
1
  {
2
- "name": "@tronweb3/tronwallet-adapter-react-ui",
3
- "version": "1.0.1",
4
- "author": "tronprotocol",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/tronprotocol/tronwallet-adapter"
2
+ "name": "@tronweb3/tronwallet-adapter-react-ui",
3
+ "version": "1.1.1",
4
+ "keywords": [
5
+ "TRON",
6
+ "TronWeb",
7
+ "adapter"
8
+ ],
9
+ "author": "tronprotocol",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/tronprotocol/tronwallet-adapter"
13
+ },
14
+ "license": "MIT",
15
+ "type": "module",
16
+ "sideEffects": false,
17
+ "engines": {
18
+ "node": ">=16",
19
+ "pnpm": ">=7"
20
+ },
21
+ "main": "./lib/cjs/index.js",
22
+ "module": "./lib/esm/index.js",
23
+ "types": "./lib/types/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "import": "./lib/esm/index.js",
27
+ "require": "./lib/cjs/index.js",
28
+ "types": "./lib/types/index.d.ts"
8
29
  },
9
- "license": "MIT",
10
- "type": "module",
11
- "sideEffects": false,
12
- "engines": {
13
- "node": ">=16",
14
- "pnpm": ">=7"
15
- },
16
- "main": "./lib/cjs/index.js",
17
- "module": "./lib/esm/index.js",
18
- "types": "./lib/types/index.d.ts",
19
- "exports": {
20
- ".": {
21
- "import": "./lib/esm/index.js",
22
- "require": "./lib/cjs/index.js",
23
- "types": "./lib/types/index.d.ts"
24
- },
25
- "./style.css": "./style.css"
26
- },
27
- "files": [
28
- "lib",
29
- "src",
30
- "LICENSE",
31
- "style.css"
32
- ],
33
- "publishConfig": {
34
- "access": "public"
35
- },
36
- "scripts": {
37
- "clean": "shx mkdir -p lib && shx rm -rf lib",
38
- "package": "shx echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json",
39
- "test": "jest"
40
- },
41
- "peerDependencies": {
42
- "react": "*",
43
- "react-dom": "*"
44
- },
45
- "dependencies": {
46
- "@tronweb3/tronwallet-abstract-adapter": "^1.0.0",
47
- "@tronweb3/tronwallet-adapter-react-hooks": "^1.0.0"
48
- },
49
- "devDependencies": {
50
- "@testing-library/jest-dom": "^5.16.5",
51
- "@testing-library/react": "^13.4.0",
52
- "@testing-library/user-event": "^13.5.0",
53
- "@tronweb3/tronwallet-adapter-tronlink": "^1.0.0",
54
- "@types/jest": "^27.5.2",
55
- "@types/react": "^18.0.26",
56
- "@types/react-dom": "^18.0.0",
57
- "@types/testing-library__jest-dom": "^5.14.5",
58
- "jest": "^29.3.1",
59
- "jest-environment-jsdom": "^29.3.1",
60
- "jest-localstorage-mock": "^2.4.22",
61
- "react": "^18.0.0",
62
- "react-dom": "^18.0.0",
63
- "shx": "^0.3.4"
64
- }
65
- }
30
+ "./style.css": "./style.css"
31
+ },
32
+ "files": [
33
+ "lib",
34
+ "src",
35
+ "LICENSE",
36
+ "style.css"
37
+ ],
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "peerDependencies": {
42
+ "react": "*",
43
+ "react-dom": "*"
44
+ },
45
+ "dependencies": {
46
+ "@tronweb3/tronwallet-abstract-adapter": "^1.1.0",
47
+ "@tronweb3/tronwallet-adapter-react-hooks": "^1.1.0"
48
+ },
49
+ "devDependencies": {
50
+ "@testing-library/jest-dom": "^5.16.5",
51
+ "@testing-library/react": "^13.4.0",
52
+ "@testing-library/user-event": "^13.5.0",
53
+ "@tronweb3/tronwallet-adapter-tronlink": "^1.1.0",
54
+ "@types/jest": "^27.5.2",
55
+ "@types/react": "^18.0.26",
56
+ "@types/react-dom": "^18.0.0",
57
+ "@types/testing-library__jest-dom": "^5.14.5",
58
+ "jest": "^29.3.1",
59
+ "jest-environment-jsdom": "^29.3.1",
60
+ "jest-localstorage-mock": "^2.4.22",
61
+ "react": "^18.0.0",
62
+ "react-dom": "^18.0.0",
63
+ "shx": "^0.3.4"
64
+ },
65
+ "scripts": {
66
+ "clean": "shx mkdir -p lib && shx rm -rf lib",
67
+ "package": "shx echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json",
68
+ "test": "jest"
69
+ }
70
+ }
package/src/Collapse.tsx CHANGED
@@ -6,6 +6,8 @@ export type CollapseProps = PropsWithChildren<{
6
6
  id?: string;
7
7
  className?: string;
8
8
  transition?: string;
9
+ onMouseEnter?: () => void;
10
+ onMouseLeave?: () => void;
9
11
  }>;
10
12
 
11
13
  export const Collapse: FC<CollapseProps> = function ({
@@ -13,6 +15,8 @@ export const Collapse: FC<CollapseProps> = function ({
13
15
  className,
14
16
  transition = 'height 250ms ease-out',
15
17
  isOpen,
18
+ onMouseEnter,
19
+ onMouseLeave,
16
20
  }) {
17
21
  const initialState = { height: '0px', transition };
18
22
  const wrapRef = useRef<HTMLDivElement>(null);
@@ -61,6 +65,8 @@ export const Collapse: FC<CollapseProps> = function ({
61
65
  overflow: 'hidden',
62
66
  ...style,
63
67
  }}
68
+ onMouseEnter={onMouseEnter}
69
+ onMouseLeave={onMouseLeave}
64
70
  >
65
71
  {children}
66
72
  </div>
@@ -68,30 +68,48 @@ export const WalletActionButton: FC<ButtonProps> = ({ children, ...props }) => {
68
68
  };
69
69
  }, [ref, hideDropdown]);
70
70
 
71
- if (!wallet) return <WalletSelectButton {...props}>{children}</WalletSelectButton>;
72
- if (!address) return <WalletConnectButton {...props}>{children}</WalletConnectButton>;
71
+ if (!wallet)
72
+ return (
73
+ <WalletSelectButton onClick={hideDropdown} {...props}>
74
+ {children}
75
+ </WalletSelectButton>
76
+ );
73
77
 
74
78
  return (
75
79
  <div data-testid="wallet-action-button" className="adapter-dropdown">
76
- <Button
77
- onClick={openDropdown}
78
- style={{ pointerEvents: dropdownVisible ? 'none' : 'auto', ...props.style }}
79
- icon={wallet ? wallet.adapter.icon : ''}
80
- {...props}
80
+ {!address ? (
81
+ <div onMouseEnter={openDropdown} onMouseLeave={hideDropdown}>
82
+ <WalletConnectButton {...props}>{children}</WalletConnectButton>
83
+ </div>
84
+ ) : (
85
+ <Button
86
+ onClick={openDropdown}
87
+ style={{ pointerEvents: dropdownVisible ? 'none' : 'auto', ...props.style }}
88
+ icon={wallet ? wallet.adapter.icon : ''}
89
+ {...props}
90
+ >
91
+ {content}
92
+ </Button>
93
+ )}
94
+ <Collapse
95
+ className="adapter-dropdown-collapse"
96
+ isOpen={dropdownVisible}
97
+ {...(!address ? { onMouseEnter: openDropdown, onMouseLeave: hideDropdown } : {})}
81
98
  >
82
- {content}
83
- </Button>
84
- <Collapse className="adapter-dropdown-collapse" isOpen={dropdownVisible}>
85
99
  <ul ref={ref} className="adapter-dropdown-list" role="menu">
86
- <li onClick={copyAddress} className="adapter-dropdown-list-item" role="menuitem">
87
- {copied ? 'Copied' : 'Copy address'}
88
- </li>
100
+ {address && (
101
+ <li onClick={copyAddress} className="adapter-dropdown-list-item" role="menuitem">
102
+ {copied ? 'Copied' : 'Copy address'}
103
+ </li>
104
+ )}
89
105
  <li onClick={changeWallet} className="adapter-dropdown-list-item" role="menuitem">
90
106
  Change wallet
91
107
  </li>
92
- <li onClick={handleDisconnect} className="adapter-dropdown-list-item" role="menuitem">
93
- Disconnect
94
- </li>
108
+ {address && (
109
+ <li onClick={handleDisconnect} className="adapter-dropdown-list-item" role="menuitem">
110
+ Disconnect
111
+ </li>
112
+ )}
95
113
  </ul>
96
114
  </Collapse>
97
115
  </div>
package/style.css CHANGED
@@ -170,9 +170,8 @@
170
170
  }
171
171
  .adapter-dropdown-collapse {
172
172
  position: absolute;
173
- top: 0;
174
173
  margin: auto;
175
- top: calc(100% + 5px);
174
+ top: 100%;
176
175
  right: 0;
177
176
  left: 0;
178
177
  display: inline-flex;
@@ -183,9 +182,12 @@
183
182
  list-style-type: none;
184
183
  border-radius: 10px;
185
184
  font-family: DM Sans, Roboto, Helvetica Neue, Helvetica, Arial, sans-serif;
186
- box-shadow: 0 2px 3px #0009;
187
185
  flex-direction: column;
186
+ position: relative;
187
+ top: 5px;
188
188
  padding: 5px;
189
+ overflow: hidden;
190
+ height: min-content;
189
191
  background: #2c2d30;
190
192
  }
191
193
  .adapter-dropdown-list li {