@tonconnect/ui-react 0.0.12 → 0.0.13

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.
@@ -42,7 +42,7 @@ export interface TonConnectUIProviderPropsBase {
42
42
  */
43
43
  walletsList?: WalletsListConfiguration;
44
44
  /**
45
- * Configuration for action-period (e.g. sendTransaction) UI elements: modals and notifications.
45
+ * Configuration for action-period (e.g. sendTransaction) UI elements: modals and notifications and wallet behaviour (return strategy).
46
46
  */
47
47
  actionsConfiguration?: ActionConfiguration;
48
48
  /**
package/lib/index.js CHANGED
@@ -11167,6 +11167,20 @@ function subscribeToThemeChange(callback) {
11167
11167
  window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", handler);
11168
11168
  return () => window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change", handler);
11169
11169
  }
11170
+ function addQueryParameter(url, key, value) {
11171
+ const parsed = new URL(url);
11172
+ parsed.searchParams.append(key, value);
11173
+ return parsed.toString();
11174
+ }
11175
+ function addReturnStrategy(url, returnStrategy) {
11176
+ return addQueryParameter(url, "ret", returnStrategy);
11177
+ }
11178
+ const [appState, setAppState] = createStore({
11179
+ buttonRootId: null,
11180
+ language: "en",
11181
+ returnStrategy: "back",
11182
+ walletsList: {}
11183
+ });
11170
11184
  const QrCodeModal = (props) => {
11171
11185
  const connector = useContext(ConnectorContext);
11172
11186
  const universalLink = connector.connect({
@@ -11217,7 +11231,7 @@ const QrCodeModal = (props) => {
11217
11231
  setLastSelectedWalletInfo(__spreadProps(__spreadValues({}, props.wallet), {
11218
11232
  openMethod: "universal-link"
11219
11233
  }));
11220
- openLink(universalLink);
11234
+ openLink(addReturnStrategy(universalLink, appState.returnStrategy));
11221
11235
  },
11222
11236
  get children() {
11223
11237
  return createComponent(Translation, {
@@ -11457,11 +11471,6 @@ const LoaderContainerStyled = styled.div`
11457
11471
  align-items: center;
11458
11472
  }
11459
11473
  `;
11460
- const [appState, setAppState] = createStore({
11461
- buttonRootId: null,
11462
- language: "en",
11463
- walletsList: {}
11464
- });
11465
11474
  function uiWalletToWalletInfo(uiWallet) {
11466
11475
  if ("jsBridgeKey" in uiWallet) {
11467
11476
  return __spreadProps(__spreadValues({}, uiWallet), {
@@ -11565,14 +11574,14 @@ const WalletsModal = () => {
11565
11574
  setSelectedWalletInfo(walletInfo);
11566
11575
  return;
11567
11576
  }
11568
- openLink(walletInfo.aboutUrl, "_blank");
11577
+ openLinkBlank(walletInfo.aboutUrl);
11569
11578
  };
11570
11579
  const onSelectIfMobile = (walletInfo) => {
11571
11580
  const universalLink = connector.connect({
11572
11581
  universalLink: walletInfo.universalLink,
11573
11582
  bridgeUrl: walletInfo.bridgeUrl
11574
11583
  }, additionalRequest());
11575
- openLink(universalLink);
11584
+ openLink(addReturnStrategy(universalLink, appState.returnStrategy));
11576
11585
  };
11577
11586
  const onSelectIfInjected = (walletInfo) => {
11578
11587
  connector.connect({
@@ -11962,8 +11971,11 @@ class TonConnectUI {
11962
11971
  setBorderRadius(options.uiPreferences.borderRadius);
11963
11972
  }
11964
11973
  setAppState((state) => {
11974
+ var _a2;
11965
11975
  const merged = mergeOptions(
11966
- __spreadValues(__spreadValues({}, options.language && { language: options.language }), !!options.walletsList && { walletsList: options.walletsList }),
11976
+ __spreadValues(__spreadValues(__spreadValues({}, options.language && { language: options.language }), !!((_a2 = options.actionsConfiguration) == null ? void 0 : _a2.returnStrategy) && {
11977
+ returnStrategy: options.actionsConfiguration.returnStrategy
11978
+ }), !!options.walletsList && { walletsList: options.walletsList }),
11967
11979
  unwrap(state)
11968
11980
  );
11969
11981
  if (options.buttonRootId !== void 0) {
@@ -12023,10 +12035,10 @@ class TonConnectUI {
12023
12035
  if (!this.connected || !this.walletInfo) {
12024
12036
  throw new TonConnectUIError("Connect wallet to send a transaction.");
12025
12037
  }
12038
+ const { notifications: notifications2, modals, returnStrategy } = this.getModalsAndNotificationsConfiguration(options);
12026
12039
  if ("universalLink" in this.walletInfo && this.walletInfo.openMethod === "universal-link") {
12027
- openLink(this.walletInfo.universalLink);
12040
+ openLink(addReturnStrategy(this.walletInfo.universalLink, returnStrategy));
12028
12041
  }
12029
- const { notifications: notifications2, modals } = this.getModalsAndNotificationsConfiguration(options);
12030
12042
  widgetController.setAction({
12031
12043
  name: "confirm-transaction",
12032
12044
  showNotification: notifications2.includes("before"),
@@ -12125,7 +12137,8 @@ class TonConnectUI {
12125
12137
  }
12126
12138
  return {
12127
12139
  notifications: notifications2,
12128
- modals
12140
+ modals,
12141
+ returnStrategy: (options == null ? void 0 : options.returnStrategy) || "back"
12129
12142
  };
12130
12143
  }
12131
12144
  }