@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.
package/lib/index.umd.js CHANGED
@@ -11170,6 +11170,20 @@ var __objRest = (source, exclude) => {
11170
11170
  window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", handler);
11171
11171
  return () => window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change", handler);
11172
11172
  }
11173
+ function addQueryParameter(url, key, value) {
11174
+ const parsed = new URL(url);
11175
+ parsed.searchParams.append(key, value);
11176
+ return parsed.toString();
11177
+ }
11178
+ function addReturnStrategy(url, returnStrategy) {
11179
+ return addQueryParameter(url, "ret", returnStrategy);
11180
+ }
11181
+ const [appState, setAppState] = createStore({
11182
+ buttonRootId: null,
11183
+ language: "en",
11184
+ returnStrategy: "back",
11185
+ walletsList: {}
11186
+ });
11173
11187
  const QrCodeModal = (props) => {
11174
11188
  const connector = useContext(ConnectorContext);
11175
11189
  const universalLink = connector.connect({
@@ -11220,7 +11234,7 @@ var __objRest = (source, exclude) => {
11220
11234
  setLastSelectedWalletInfo(__spreadProps(__spreadValues({}, props.wallet), {
11221
11235
  openMethod: "universal-link"
11222
11236
  }));
11223
- openLink(universalLink);
11237
+ openLink(addReturnStrategy(universalLink, appState.returnStrategy));
11224
11238
  },
11225
11239
  get children() {
11226
11240
  return createComponent(Translation, {
@@ -11460,11 +11474,6 @@ var __objRest = (source, exclude) => {
11460
11474
  align-items: center;
11461
11475
  }
11462
11476
  `;
11463
- const [appState, setAppState] = createStore({
11464
- buttonRootId: null,
11465
- language: "en",
11466
- walletsList: {}
11467
- });
11468
11477
  function uiWalletToWalletInfo(uiWallet) {
11469
11478
  if ("jsBridgeKey" in uiWallet) {
11470
11479
  return __spreadProps(__spreadValues({}, uiWallet), {
@@ -11568,14 +11577,14 @@ var __objRest = (source, exclude) => {
11568
11577
  setSelectedWalletInfo(walletInfo);
11569
11578
  return;
11570
11579
  }
11571
- openLink(walletInfo.aboutUrl, "_blank");
11580
+ openLinkBlank(walletInfo.aboutUrl);
11572
11581
  };
11573
11582
  const onSelectIfMobile = (walletInfo) => {
11574
11583
  const universalLink = connector.connect({
11575
11584
  universalLink: walletInfo.universalLink,
11576
11585
  bridgeUrl: walletInfo.bridgeUrl
11577
11586
  }, additionalRequest());
11578
- openLink(universalLink);
11587
+ openLink(addReturnStrategy(universalLink, appState.returnStrategy));
11579
11588
  };
11580
11589
  const onSelectIfInjected = (walletInfo) => {
11581
11590
  connector.connect({
@@ -11965,8 +11974,11 @@ var __objRest = (source, exclude) => {
11965
11974
  setBorderRadius(options.uiPreferences.borderRadius);
11966
11975
  }
11967
11976
  setAppState((state) => {
11977
+ var _a2;
11968
11978
  const merged = mergeOptions(
11969
- __spreadValues(__spreadValues({}, options.language && { language: options.language }), !!options.walletsList && { walletsList: options.walletsList }),
11979
+ __spreadValues(__spreadValues(__spreadValues({}, options.language && { language: options.language }), !!((_a2 = options.actionsConfiguration) == null ? void 0 : _a2.returnStrategy) && {
11980
+ returnStrategy: options.actionsConfiguration.returnStrategy
11981
+ }), !!options.walletsList && { walletsList: options.walletsList }),
11970
11982
  unwrap(state)
11971
11983
  );
11972
11984
  if (options.buttonRootId !== void 0) {
@@ -12026,10 +12038,10 @@ var __objRest = (source, exclude) => {
12026
12038
  if (!this.connected || !this.walletInfo) {
12027
12039
  throw new TonConnectUIError("Connect wallet to send a transaction.");
12028
12040
  }
12041
+ const { notifications: notifications2, modals, returnStrategy } = this.getModalsAndNotificationsConfiguration(options);
12029
12042
  if ("universalLink" in this.walletInfo && this.walletInfo.openMethod === "universal-link") {
12030
- openLink(this.walletInfo.universalLink);
12043
+ openLink(addReturnStrategy(this.walletInfo.universalLink, returnStrategy));
12031
12044
  }
12032
- const { notifications: notifications2, modals } = this.getModalsAndNotificationsConfiguration(options);
12033
12045
  widgetController.setAction({
12034
12046
  name: "confirm-transaction",
12035
12047
  showNotification: notifications2.includes("before"),
@@ -12128,7 +12140,8 @@ var __objRest = (source, exclude) => {
12128
12140
  }
12129
12141
  return {
12130
12142
  notifications: notifications2,
12131
- modals
12143
+ modals,
12144
+ returnStrategy: (options == null ? void 0 : options.returnStrategy) || "back"
12132
12145
  };
12133
12146
  }
12134
12147
  }