@tonconnect/ui-react 2.0.0-beta.1 → 2.0.0-beta.10
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/README.md +97 -0
- package/lib/components/TonConnectUIProvider.d.ts +5 -0
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/useTonConnectModal.d.ts +5 -0
- package/lib/index.cjs +1100 -0
- package/lib/index.cjs.map +1 -0
- package/lib/{index.js → index.mjs} +26 -1
- package/lib/index.mjs.map +1 -0
- package/package.json +7 -7
- package/lib/index.js.map +0 -1
- package/lib/index.umd.js +0 -1077
- package/lib/index.umd.js.map +0 -1
package/README.md
CHANGED
|
@@ -107,6 +107,26 @@ export const Wallet = () => {
|
|
|
107
107
|
};
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
+
### useTonConnectModal
|
|
111
|
+
|
|
112
|
+
Use this hook to access the functions for opening and closing the modal window. The hook returns an object with the current modal state and methods to open and close the modal.
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
import { useTonConnectModal } from '@tonconnect/ui-react';
|
|
116
|
+
|
|
117
|
+
export const ModalControl = () => {
|
|
118
|
+
const { state, open, close } = useTonConnectModal();
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<div>
|
|
122
|
+
<div>Modal state: {state?.status}</div>
|
|
123
|
+
<button onClick={open}>Open modal</button>
|
|
124
|
+
<button onClick={close}>Close modal</button>
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
```
|
|
129
|
+
|
|
110
130
|
### useTonConnectUI
|
|
111
131
|
Use it to get access to the `TonConnectUI` instance and UI options updating function.
|
|
112
132
|
|
|
@@ -256,3 +276,80 @@ useEffect(() =>
|
|
|
256
276
|
}), []);
|
|
257
277
|
```
|
|
258
278
|
|
|
279
|
+
# Troubleshooting
|
|
280
|
+
|
|
281
|
+
## Android Back Handler
|
|
282
|
+
|
|
283
|
+
If you encounter any issues with the Android back handler, such as modals not closing properly when the back button is pressed, or conflicts with `history.pushState()` if you are manually handling browser history in your application, you can disable the back handler by setting `enableAndroidBackHandler` to `false`:
|
|
284
|
+
|
|
285
|
+
```tsx
|
|
286
|
+
import { TonConnectUIProvider } from '@tonconnect/ui-react';
|
|
287
|
+
|
|
288
|
+
export function App() {
|
|
289
|
+
return (
|
|
290
|
+
<TonConnectUIProvider
|
|
291
|
+
manifestUrl="https://<YOUR_APP_URL>/tonconnect-manifest.json"
|
|
292
|
+
enableAndroidBackHandler={false}
|
|
293
|
+
>
|
|
294
|
+
{ /* Your app */ }
|
|
295
|
+
</TonConnectUIProvider>
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
This will disable the custom back button behavior on Android, and you can then handle the back button press manually in your application.
|
|
301
|
+
|
|
302
|
+
While we do not foresee any problems arising with the Android back handler, but if you find yourself needing to disable it due to an issue, please describe the problem in on [GitHub Issues](https://github.com/ton-connect/sdk/issues), so we can assist you further.
|
|
303
|
+
|
|
304
|
+
## Animations not working
|
|
305
|
+
|
|
306
|
+
If you are experiencing issues with animations not working in your environment, it might be due to a lack of support for the Web Animations API. To resolve this issue, you can use the `web-animations-js` polyfill.
|
|
307
|
+
|
|
308
|
+
### Using npm
|
|
309
|
+
|
|
310
|
+
To install the polyfill, run the following command:
|
|
311
|
+
|
|
312
|
+
```shell
|
|
313
|
+
npm install web-animations-js
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Then, import the polyfill in your project:
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
import 'web-animations-js';
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Using CDN
|
|
323
|
+
|
|
324
|
+
Alternatively, you can include the polyfill via CDN by adding the following script tag to your HTML:
|
|
325
|
+
|
|
326
|
+
```html
|
|
327
|
+
<script src="https://www.unpkg.com/web-animations-js@latest/web-animations.min.js"></script>
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Both methods will provide a fallback implementation of the Web Animations API and should resolve the animation issues you are facing.
|
|
331
|
+
|
|
332
|
+
## Warning about 'encoding' module in Next.js
|
|
333
|
+
|
|
334
|
+
If you are using Next.js and see a warning similar to the following:
|
|
335
|
+
|
|
336
|
+
```
|
|
337
|
+
⚠ ./node_modules/node-fetch/lib/index.js
|
|
338
|
+
Module not found: Can't resolve 'encoding' in '.../node_modules/node-fetch/lib'
|
|
339
|
+
|
|
340
|
+
Import trace for requested module:
|
|
341
|
+
./node_modules/node-fetch/lib/index.js
|
|
342
|
+
./node_modules/@tonconnect/isomorphic-fetch/index.mjs
|
|
343
|
+
./node_modules/@tonconnect/sdk/lib/esm/index.mjs
|
|
344
|
+
./node_modules/@tonconnect/ui/lib/esm/index.mjs
|
|
345
|
+
./node_modules/@tonconnect/ui-react/lib/esm/index.js
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
Please note that this is just a warning and should not affect the functionality of your application. If you wish to suppress the warning, you have two options:
|
|
349
|
+
|
|
350
|
+
1. (Recommended) Wait for us to remove the dependency on `@tonconnect/isomorphic-fetch` in future releases. This dependency will be removed when we drop support for Node.js versions below 18.
|
|
351
|
+
|
|
352
|
+
2. (Optional) Install the `encoding` package, to resolve the warning:
|
|
353
|
+
```shell
|
|
354
|
+
npm install encoding
|
|
355
|
+
```
|
|
@@ -46,6 +46,11 @@ export interface TonConnectUIProviderPropsBase {
|
|
|
46
46
|
* Configuration for action-period (e.g. sendTransaction) UI elements: modals and notifications and wallet behaviour (return strategy).
|
|
47
47
|
*/
|
|
48
48
|
actionsConfiguration?: ActionConfiguration;
|
|
49
|
+
/**
|
|
50
|
+
* Specifies whether the Android back button should be used to close modals and notifications on Android devices.
|
|
51
|
+
* @default true
|
|
52
|
+
*/
|
|
53
|
+
enableAndroidBackHandler?: boolean;
|
|
49
54
|
}
|
|
50
55
|
declare const _default: import("react").NamedExoticComponent<TonConnectUIProviderProps>;
|
|
51
56
|
export default _default;
|
package/lib/hooks/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { useTonAddress } from './useTonAddress';
|
|
2
|
+
export { useTonConnectModal } from './useTonConnectModal';
|
|
2
3
|
export { useTonConnectUI } from './useTonConnectUI';
|
|
3
4
|
export { useTonWallet } from './useTonWallet';
|
|
4
5
|
export { useIsConnectionRestored } from './useIsConnectionRestored';
|