@miden-sdk/miden-wallet-adapter-reactui 0.15.3 → 0.16.0-rc.5

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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Button.d.ts +2 -2
  3. package/dist/Button.js +1 -1
  4. package/dist/Collapse.d.ts +1 -1
  5. package/dist/Collapse.js +16 -13
  6. package/dist/Collapse.js.map +1 -1
  7. package/dist/DiscoverMidenMessage.d.ts +1 -1
  8. package/dist/DiscoverMidenMessage.js +1 -1
  9. package/dist/DiscoverMidenMessage.js.map +1 -1
  10. package/dist/MidenSVG.d.ts +1 -1
  11. package/dist/MidenSVG.js.map +1 -1
  12. package/dist/WalletConnectButton.d.ts +2 -2
  13. package/dist/WalletConnectButton.js +9 -9
  14. package/dist/WalletConnectButton.js.map +1 -1
  15. package/dist/WalletDisconnectButton.d.ts +2 -2
  16. package/dist/WalletDisconnectButton.js +7 -7
  17. package/dist/WalletIcon.d.ts +2 -2
  18. package/dist/WalletIcon.js.map +1 -1
  19. package/dist/WalletListItem.d.ts +3 -2
  20. package/dist/WalletListItem.js +3 -3
  21. package/dist/WalletListItem.js.map +1 -1
  22. package/dist/WalletModal.d.ts +2 -2
  23. package/dist/WalletModal.js +16 -16
  24. package/dist/WalletModal.js.map +1 -1
  25. package/dist/WalletModalButton.d.ts +2 -2
  26. package/dist/WalletModalButton.js +4 -4
  27. package/dist/WalletModalButton.js.map +1 -1
  28. package/dist/WalletModalProvider.d.ts +2 -2
  29. package/dist/WalletModalProvider.js +3 -3
  30. package/dist/WalletModalProvider.js.map +1 -1
  31. package/dist/WalletMultiButton.d.ts +2 -2
  32. package/dist/WalletMultiButton.js +19 -19
  33. package/dist/WalletMultiButton.js.map +1 -1
  34. package/dist/index.d.ts +8 -8
  35. package/dist/index.js +8 -8
  36. package/dist/styles.css +22 -19
  37. package/dist/useWalletModal.js +9 -9
  38. package/dist/useWalletModal.js.map +1 -1
  39. package/package.json +18 -13
  40. package/src/Button.tsx +3 -3
  41. package/src/Collapse.tsx +73 -66
  42. package/src/DiscoverMidenMessage.tsx +5 -7
  43. package/src/MidenSVG.tsx +37 -16
  44. package/src/WalletConnectButton.tsx +15 -11
  45. package/src/WalletDisconnectButton.tsx +9 -9
  46. package/src/WalletIcon.tsx +6 -7
  47. package/src/WalletListItem.tsx +6 -5
  48. package/src/WalletModal.tsx +18 -24
  49. package/src/WalletModalButton.tsx +27 -19
  50. package/src/WalletModalProvider.tsx +22 -19
  51. package/src/WalletMultiButton.tsx +22 -28
  52. package/src/index.ts +8 -8
  53. package/src/useWalletModal.tsx +28 -23
  54. package/styles.css +22 -19
  55. package/tsconfig.json +3 -3
  56. package/yarn-error.log +0 -525
@@ -1,24 +1,18 @@
1
- import type { FC, MouseEvent } from 'react';
2
- import {
3
- useCallback,
4
- useLayoutEffect,
5
- useMemo,
6
- useRef,
7
- useState,
8
- } from 'react';
9
- import { createPortal } from 'react-dom';
1
+ import type { FC, MouseEvent } from "react";
2
+ import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
3
+ import { createPortal } from "react-dom";
10
4
  import {
11
5
  AllowedPrivateData,
12
6
  PrivateDataPermission,
13
7
  WalletAdapterNetwork,
14
8
  WalletName,
15
9
  WalletReadyState,
16
- } from '@miden-sdk/miden-wallet-adapter-base';
17
- import { useWallet, Wallet } from '@miden-sdk/miden-wallet-adapter-react';
18
- import { MidenWalletName } from '@miden-sdk/miden-wallet-adapter-miden';
19
- import { useWalletModal } from './useWalletModal';
20
- import { WalletListItem } from './WalletListItem';
21
- import { DiscoverMidenMessage } from './DiscoverMidenMessage';
10
+ } from "@miden-sdk/miden-wallet-adapter-base";
11
+ import { useWallet, Wallet } from "@miden-sdk/miden-wallet-adapter-react";
12
+ import { MidenWalletName } from "@miden-sdk/miden-wallet-adapter-miden";
13
+ import { useWalletModal } from "./useWalletModal";
14
+ import { WalletListItem } from "./WalletListItem";
15
+ import { DiscoverMidenMessage } from "./DiscoverMidenMessage";
22
16
 
23
17
  export interface WalletModalProps {
24
18
  className?: string;
@@ -29,8 +23,8 @@ export interface WalletModalProps {
29
23
  }
30
24
 
31
25
  export const WalletModal: FC<WalletModalProps> = ({
32
- className = '',
33
- container = 'body',
26
+ className = "",
27
+ container = "body",
34
28
  privateDataPermission,
35
29
  network,
36
30
  allowedPrivateData,
@@ -104,7 +98,7 @@ export const WalletModal: FC<WalletModalProps> = ({
104
98
  if (!node) return;
105
99
 
106
100
  // here we query all focusable elements
107
- const focusableElements = node.querySelectorAll('button');
101
+ const focusableElements = node.querySelectorAll("button");
108
102
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
109
103
  const firstElement = focusableElements[0]!;
110
104
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -129,9 +123,9 @@ export const WalletModal: FC<WalletModalProps> = ({
129
123
 
130
124
  useLayoutEffect(() => {
131
125
  const handleKeyDown = (event: KeyboardEvent) => {
132
- if (event.key === 'Escape') {
126
+ if (event.key === "Escape") {
133
127
  hideModal();
134
- } else if (event.key === 'Tab') {
128
+ } else if (event.key === "Tab") {
135
129
  handleTabKey(event);
136
130
  }
137
131
  };
@@ -141,14 +135,14 @@ export const WalletModal: FC<WalletModalProps> = ({
141
135
  // Hack to enable fade in animation after mount
142
136
  setTimeout(() => setFadeIn(true), 0);
143
137
  // Prevent scrolling on mount
144
- document.body.style.overflow = 'hidden';
138
+ document.body.style.overflow = "hidden";
145
139
  // Listen for keydown events
146
- window.addEventListener('keydown', handleKeyDown, false);
140
+ window.addEventListener("keydown", handleKeyDown, false);
147
141
 
148
142
  return () => {
149
143
  // Re-enable scrolling when component unmounts
150
144
  document.body.style.overflow = overflow;
151
- window.removeEventListener('keydown', handleKeyDown, false);
145
+ window.removeEventListener("keydown", handleKeyDown, false);
152
146
  };
153
147
  }, [hideModal, handleTabKey]);
154
148
 
@@ -176,7 +170,7 @@ export const WalletModal: FC<WalletModalProps> = ({
176
170
  aria-labelledby="wallet-adapter-modal-title"
177
171
  aria-modal="true"
178
172
  className={`wallet-adapter-modal ${
179
- fadeIn && 'wallet-adapter-modal-fade-in'
173
+ fadeIn && "wallet-adapter-modal-fade-in"
180
174
  } ${className}`}
181
175
  ref={ref}
182
176
  role="dialog"
@@ -1,23 +1,31 @@
1
- import type { FC, MouseEvent } from 'react';
2
- import { useCallback } from 'react';
3
- import type { ButtonProps } from './Button';
4
- import { Button } from './Button';
5
- import { useWalletModal } from './useWalletModal';
1
+ import type { FC, MouseEvent } from "react";
2
+ import { useCallback } from "react";
3
+ import type { ButtonProps } from "./Button";
4
+ import { Button } from "./Button";
5
+ import { useWalletModal } from "./useWalletModal";
6
6
 
7
- export const WalletModalButton: FC<ButtonProps> = ({ children = 'Select Wallet', onClick, ...props }) => {
8
- const { visible, setVisible } = useWalletModal();
7
+ export const WalletModalButton: FC<ButtonProps> = ({
8
+ children = "Select Wallet",
9
+ onClick,
10
+ ...props
11
+ }) => {
12
+ const { visible, setVisible } = useWalletModal();
9
13
 
10
- const handleClick = useCallback(
11
- (event: MouseEvent<HTMLButtonElement>) => {
12
- if (onClick) onClick(event);
13
- if (!event.defaultPrevented) setVisible(!visible);
14
- },
15
- [onClick, setVisible, visible]
16
- );
14
+ const handleClick = useCallback(
15
+ (event: MouseEvent<HTMLButtonElement>) => {
16
+ if (onClick) onClick(event);
17
+ if (!event.defaultPrevented) setVisible(!visible);
18
+ },
19
+ [onClick, setVisible, visible]
20
+ );
17
21
 
18
- return (
19
- <Button className="wallet-adapter-button-trigger" onClick={handleClick} {...props}>
20
- {children}
21
- </Button>
22
- );
22
+ return (
23
+ <Button
24
+ className="wallet-adapter-button-trigger"
25
+ onClick={handleClick}
26
+ {...props}
27
+ >
28
+ {children}
29
+ </Button>
30
+ );
23
31
  };
@@ -1,25 +1,28 @@
1
- import type { FC, ReactNode } from 'react';
2
- import React, { useState } from 'react';
3
- import { WalletModalContext } from './useWalletModal';
4
- import type { WalletModalProps } from './WalletModal';
5
- import { WalletModal } from './WalletModal';
1
+ import type { FC, ReactNode } from "react";
2
+ import React, { useState } from "react";
3
+ import { WalletModalContext } from "./useWalletModal";
4
+ import type { WalletModalProps } from "./WalletModal";
5
+ import { WalletModal } from "./WalletModal";
6
6
 
7
7
  export interface WalletModalProviderProps extends WalletModalProps {
8
- children: ReactNode;
8
+ children: ReactNode;
9
9
  }
10
10
 
11
- export const WalletModalProvider: FC<WalletModalProviderProps> = ({ children, ...props }) => {
12
- const [visible, setVisible] = useState(false);
11
+ export const WalletModalProvider: FC<WalletModalProviderProps> = ({
12
+ children,
13
+ ...props
14
+ }) => {
15
+ const [visible, setVisible] = useState(false);
13
16
 
14
- return (
15
- <WalletModalContext.Provider
16
- value={{
17
- visible,
18
- setVisible,
19
- }}
20
- >
21
- {children}
22
- {visible && <WalletModal {...props} />}
23
- </WalletModalContext.Provider>
24
- );
17
+ return (
18
+ <WalletModalContext.Provider
19
+ value={{
20
+ visible,
21
+ setVisible,
22
+ }}
23
+ >
24
+ {children}
25
+ {visible && <WalletModal {...props} />}
26
+ </WalletModalContext.Provider>
27
+ );
25
28
  };
@@ -1,18 +1,12 @@
1
- import type { FC } from 'react';
2
- import {
3
- useCallback,
4
- useEffect,
5
- useMemo,
6
- useRef,
7
- useState,
8
- } from 'react';
9
- import { useWallet } from '@miden-sdk/miden-wallet-adapter-react';
10
- import type { ButtonProps } from './Button';
11
- import { Button } from './Button';
12
- import { useWalletModal } from './useWalletModal';
13
- import { WalletConnectButton } from './WalletConnectButton';
14
- import { WalletIcon } from './WalletIcon';
15
- import { WalletModalButton } from './WalletModalButton';
1
+ import type { FC } from "react";
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+ import { useWallet } from "@miden-sdk/miden-wallet-adapter-react";
4
+ import type { ButtonProps } from "./Button";
5
+ import { Button } from "./Button";
6
+ import { useWalletModal } from "./useWalletModal";
7
+ import { WalletConnectButton } from "./WalletConnectButton";
8
+ import { WalletIcon } from "./WalletIcon";
9
+ import { WalletModalButton } from "./WalletModalButton";
16
10
 
17
11
  export const WalletMultiButton: FC<ButtonProps> = ({ children, ...props }) => {
18
12
  const { address, wallet, disconnect } = useWallet();
@@ -25,7 +19,7 @@ export const WalletMultiButton: FC<ButtonProps> = ({ children, ...props }) => {
25
19
  if (children) return children;
26
20
  if (!wallet || !address) return null;
27
21
 
28
- const underscoreIndex = address.indexOf('_');
22
+ const underscoreIndex = address.indexOf("_");
29
23
  const frontPart = address.slice(0, 6);
30
24
  const middlePart = address.slice(underscoreIndex - 4, underscoreIndex);
31
25
  return `${frontPart}...${middlePart}`;
@@ -62,12 +56,12 @@ export const WalletMultiButton: FC<ButtonProps> = ({ children, ...props }) => {
62
56
  closeDropdown();
63
57
  };
64
58
 
65
- document.addEventListener('mousedown', listener);
66
- document.addEventListener('touchstart', listener);
59
+ document.addEventListener("mousedown", listener);
60
+ document.addEventListener("touchstart", listener);
67
61
 
68
62
  return () => {
69
- document.removeEventListener('mousedown', listener);
70
- document.removeEventListener('touchstart', listener);
63
+ document.removeEventListener("mousedown", listener);
64
+ document.removeEventListener("touchstart", listener);
71
65
  };
72
66
  }, [ref, closeDropdown]);
73
67
 
@@ -82,12 +76,12 @@ export const WalletMultiButton: FC<ButtonProps> = ({ children, ...props }) => {
82
76
  aria-expanded={active}
83
77
  className="wallet-adapter-button-trigger"
84
78
  style={{
85
- pointerEvents: active ? 'none' : 'auto',
86
- width: '100%',
87
- backgroundColor: '#FFFFFF',
88
- border: '1px solid #D7D7D7',
89
- color: 'black',
90
- ...props.style
79
+ pointerEvents: active ? "none" : "auto",
80
+ width: "100%",
81
+ backgroundColor: "#FFFFFF",
82
+ border: "1px solid #D7D7D7",
83
+ color: "black",
84
+ ...props.style,
91
85
  }}
92
86
  onClick={openDropdown}
93
87
  startIcon={<WalletIcon wallet={wallet} />}
@@ -98,7 +92,7 @@ export const WalletMultiButton: FC<ButtonProps> = ({ children, ...props }) => {
98
92
  <ul
99
93
  aria-label="dropdown-list"
100
94
  className={`wallet-adapter-dropdown-list ${
101
- active && 'wallet-adapter-dropdown-list-active'
95
+ active && "wallet-adapter-dropdown-list-active"
102
96
  }`}
103
97
  ref={ref}
104
98
  role="menu"
@@ -108,7 +102,7 @@ export const WalletMultiButton: FC<ButtonProps> = ({ children, ...props }) => {
108
102
  className="wallet-adapter-dropdown-list-item"
109
103
  role="menuitem"
110
104
  >
111
- {copied ? 'Copied' : 'Copy address'}
105
+ {copied ? "Copied" : "Copy address"}
112
106
  </li>
113
107
  <li
114
108
  onClick={openModal}
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
- export * from './useWalletModal';
2
- export * from './WalletConnectButton';
3
- export * from './WalletModal';
4
- export * from './WalletModalButton';
5
- export * from './WalletModalProvider';
6
- export * from './WalletDisconnectButton';
7
- export * from './WalletIcon';
8
- export * from './WalletMultiButton';
1
+ export * from "./useWalletModal";
2
+ export * from "./WalletConnectButton";
3
+ export * from "./WalletModal";
4
+ export * from "./WalletModalButton";
5
+ export * from "./WalletModalProvider";
6
+ export * from "./WalletDisconnectButton";
7
+ export * from "./WalletIcon";
8
+ export * from "./WalletMultiButton";
@@ -1,36 +1,41 @@
1
- import { createContext, useContext } from 'react';
1
+ import { createContext, useContext } from "react";
2
2
 
3
3
  export interface WalletModalContextState {
4
- visible: boolean;
5
- setVisible: (open: boolean) => void;
4
+ visible: boolean;
5
+ setVisible: (open: boolean) => void;
6
6
  }
7
7
 
8
8
  const DEFAULT_CONTEXT = {
9
- setVisible(_open: boolean) {
10
- console.error(constructMissingProviderErrorMessage('call', 'setVisible'));
11
- },
12
- visible: false,
9
+ setVisible(_open: boolean) {
10
+ console.error(constructMissingProviderErrorMessage("call", "setVisible"));
11
+ },
12
+ visible: false,
13
13
  };
14
- Object.defineProperty(DEFAULT_CONTEXT, 'visible', {
15
- get() {
16
- console.error(constructMissingProviderErrorMessage('read', 'visible'));
17
- return false;
18
- },
14
+ Object.defineProperty(DEFAULT_CONTEXT, "visible", {
15
+ get() {
16
+ console.error(constructMissingProviderErrorMessage("read", "visible"));
17
+ return false;
18
+ },
19
19
  });
20
20
 
21
- function constructMissingProviderErrorMessage(action: string, valueName: string) {
22
- return (
23
- 'You have tried to ' +
24
- `${action} "${valueName}"` +
25
- ' on a WalletModalContext without providing one.' +
26
- ' Make sure to render a WalletModalProvider' +
27
- ' as an ancestor of the component that uses ' +
28
- 'WalletModalContext'
29
- );
21
+ function constructMissingProviderErrorMessage(
22
+ action: string,
23
+ valueName: string
24
+ ) {
25
+ return (
26
+ "You have tried to " +
27
+ `${action} "${valueName}"` +
28
+ " on a WalletModalContext without providing one." +
29
+ " Make sure to render a WalletModalProvider" +
30
+ " as an ancestor of the component that uses " +
31
+ "WalletModalContext"
32
+ );
30
33
  }
31
34
 
32
- export const WalletModalContext = createContext<WalletModalContextState>(DEFAULT_CONTEXT as WalletModalContextState);
35
+ export const WalletModalContext = createContext<WalletModalContextState>(
36
+ DEFAULT_CONTEXT as WalletModalContextState
37
+ );
33
38
 
34
39
  export function useWalletModal(): WalletModalContextState {
35
- return useContext(WalletModalContext);
40
+ return useContext(WalletModalContext);
36
41
  }
package/styles.css CHANGED
@@ -1,4 +1,4 @@
1
- @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');
1
+ @import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap");
2
2
 
3
3
  .wallet-adapter-button {
4
4
  background-color: transparent;
@@ -7,8 +7,8 @@
7
7
  cursor: pointer;
8
8
  display: flex;
9
9
  align-items: center;
10
- font-family: 'Inter', 'Roboto', 'Helvetica Neue', Helvetica, Arial,
11
- sans-serif;
10
+ font-family:
11
+ "Inter", "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
12
12
  font-size: 16px;
13
13
  font-weight: 600;
14
14
  height: 48px;
@@ -18,7 +18,7 @@
18
18
  }
19
19
 
20
20
  .wallet-adapter-button-trigger {
21
- background-color: #FF5500;
21
+ background-color: #ff5500;
22
22
  }
23
23
 
24
24
  .wallet-adapter-button:not([disabled]):focus-visible {
@@ -26,11 +26,11 @@
26
26
  }
27
27
 
28
28
  .wallet-adapter-button:not([disabled]):hover {
29
- background-color: #FF5500;
29
+ background-color: #ff5500;
30
30
  }
31
31
 
32
32
  .wallet-adapter-button[disabled] {
33
- background: #F3F3F3;
33
+ background: #f3f3f3;
34
34
  color: black;
35
35
  cursor: not-allowed;
36
36
  }
@@ -83,12 +83,15 @@
83
83
  list-style: none;
84
84
  background: white;
85
85
  border-radius: 8px;
86
- box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.10);
86
+ box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.1);
87
87
  opacity: 0;
88
88
  visibility: hidden;
89
- transition: opacity 200ms ease, transform 200ms ease, visibility 200ms;
90
- font-family: 'Inter', 'Roboto', 'Helvetica Neue', Helvetica, Arial,
91
- sans-serif;
89
+ transition:
90
+ opacity 200ms ease,
91
+ transform 200ms ease,
92
+ visibility 200ms;
93
+ font-family:
94
+ "Inter", "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
92
95
  width: 100%;
93
96
  }
94
97
 
@@ -117,7 +120,7 @@
117
120
  }
118
121
 
119
122
  .wallet-adapter-dropdown-list-item:not([disabled]):hover {
120
- background-color: #F9F9F9;
123
+ background-color: #f9f9f9;
121
124
  }
122
125
 
123
126
  .wallet-adapter-modal-collapse-button svg {
@@ -164,7 +167,7 @@
164
167
  }
165
168
 
166
169
  .wallet-adapter-modal-button-close:hover {
167
- background-color: #F3F3F3;
170
+ background-color: #f3f3f3;
168
171
  }
169
172
 
170
173
  .wallet-adapter-modal-overlay {
@@ -202,8 +205,8 @@
202
205
  border-radius: 16px;
203
206
  background: white;
204
207
  box-shadow: 0px 8px 20px rgba(0, 0, 0, 0.15);
205
- font-family: 'Inter', 'Roboto', 'Helvetica Neue', Helvetica, Arial,
206
- sans-serif;
208
+ font-family:
209
+ "Inter", "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
207
210
  flex: 1;
208
211
  color: black;
209
212
  overflow: hidden;
@@ -221,11 +224,11 @@
221
224
  }
222
225
 
223
226
  .wallet-adapter-modal-wrapper .wallet-adapter-button:not([disabled]):hover {
224
- background-color: #F3F3F3;
227
+ background-color: #f3f3f3;
225
228
  }
226
229
 
227
230
  .wallet-adapter-modal-wrapper hr {
228
- background: #EBEBEB;
231
+ background: #ebebeb;
229
232
  margin-top: 16px;
230
233
  }
231
234
 
@@ -291,7 +294,7 @@
291
294
  }
292
295
 
293
296
  .wallet-adapter-modal-list .wallet-adapter-button-start-icon {
294
- border: 1px solid #E5E5E5;
297
+ border: 1px solid #e5e5e5;
295
298
  }
296
299
 
297
300
  .wallet-adapter-modal-list .wallet-adapter-button-start-icon img {
@@ -344,7 +347,7 @@
344
347
  justify-content: center;
345
348
  cursor: pointer;
346
349
  width: 100%;
347
- background-color: #FF5500;
350
+ background-color: #ff5500;
348
351
  padding: 12px 16px;
349
352
  font-size: 16px;
350
353
  font-weight: 500;
@@ -354,7 +357,7 @@
354
357
  }
355
358
 
356
359
  .wallet-adapter-modal-middle-button:not([disabled]):hover {
357
- background-color: #FF5500;
360
+ background-color: #ff5500;
358
361
  }
359
362
 
360
363
  .wallet-adapter-modal-middle-button svg {
package/tsconfig.json CHANGED
@@ -19,14 +19,14 @@
19
19
  "downlevelIteration": true,
20
20
  "outDir": "dist",
21
21
  "declaration": true,
22
- "sourceMap": true,
22
+ "sourceMap": true
23
23
  },
24
24
  "include": ["src"],
25
25
  "typedocOptions": {
26
26
  "entryPoints": ["src/index.ts"],
27
27
  "out": "docs",
28
28
  "compilerOptions": {
29
- "ignoreCompilerErrors": true
29
+ "ignoreCompilerErrors": true
30
30
  }
31
31
  }
32
- }
32
+ }