@tonconnect/ui-react 0.0.12 → 0.0.14

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
@@ -4053,7 +4053,7 @@ class BridgeProvider {
4053
4053
  this.storage = storage;
4054
4054
  this.walletConnectionSource = walletConnectionSource;
4055
4055
  this.type = "http";
4056
- this.standardUniversalLink = "https://connect.ton.org";
4056
+ this.standardUniversalLink = "tc://";
4057
4057
  this.pendingRequests = /* @__PURE__ */ new Map();
4058
4058
  this.nextRequestId = 0;
4059
4059
  this.session = null;
@@ -6822,7 +6822,8 @@ const defaultLightColorsSet = {
6822
6822
  primary: "#0F0F0F",
6823
6823
  secondary: "#7A8999",
6824
6824
  tertiary: "#C1CAD2",
6825
- success: "#29CC6A"
6825
+ success: "#29CC6A",
6826
+ error: "#F5A73B"
6826
6827
  },
6827
6828
  background: {
6828
6829
  primary: "#FFFFFF",
@@ -6847,7 +6848,8 @@ const defaultDarkColorsSet = {
6847
6848
  primary: "#E5E5EA",
6848
6849
  secondary: "#909099",
6849
6850
  tertiary: "#434347",
6850
- success: "#29CC6A"
6851
+ success: "#29CC6A",
6852
+ error: "#F5A73B"
6851
6853
  },
6852
6854
  background: {
6853
6855
  primary: "#121214",
@@ -7946,7 +7948,7 @@ const SuccessIcon = (props) => {
7946
7948
  const _tmpl$$a = /* @__PURE__ */ template$1(`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="11"></circle><path fill-rule="evenodd" clip-rule="evenodd" d="M7.86358 9.13637C7.51211 8.7849 7.51211 8.21505 7.86358 7.86358C8.21505 7.51211 8.7849 7.51211 9.13637 7.86358L12 10.7272L14.8636 7.86358C15.2151 7.51211 15.7849 7.51211 16.1364 7.86358C16.4878 8.21505 16.4878 8.7849 16.1364 9.13637L13.2728 12L16.1364 14.8636C16.4878 15.2151 16.4878 15.7849 16.1364 16.1364C15.7849 16.4878 15.2151 16.4878 14.8636 16.1364L12 13.2728L9.13637 16.1364C8.7849 16.4878 8.21505 16.4878 7.86358 16.1364C7.51211 15.7849 7.51211 15.2151 7.86358 14.8636L10.7272 12L7.86358 9.13637Z"></path></svg>`);
7947
7949
  const ErrorIcon = (props) => {
7948
7950
  const theme = useTheme();
7949
- const fill = () => props.fill || theme.colors.icon.secondary;
7951
+ const fill = () => props.fill || theme.colors.icon.error;
7950
7952
  return (() => {
7951
7953
  const _el$ = _tmpl$$a.cloneNode(true), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
7952
7954
  createRenderEffect((_p$) => {
@@ -8111,6 +8113,7 @@ const AccountButtonDropdown = (props) => {
8111
8113
  setTimeout(() => setIsCopiedShown(false), 1e3);
8112
8114
  });
8113
8115
  const onDisconnect = () => {
8116
+ setAction(null);
8114
8117
  connector.disconnect();
8115
8118
  props.onClose();
8116
8119
  };
@@ -8301,9 +8304,10 @@ const NotificationClass = u`
8301
8304
  `;
8302
8305
  const _tmpl$$4 = /* @__PURE__ */ template$1(`<div></div>`);
8303
8306
  const Notifications = (props) => {
8307
+ const timeouts = [];
8308
+ const [openedNotifications, setOpenedNotifications] = createSignal([]);
8304
8309
  let lastId = -1;
8305
8310
  const liveTimeoutMs = 4500;
8306
- const [openedNotifications, setOpenedNotifications] = createSignal([]);
8307
8311
  createEffect(on(action, (action2) => {
8308
8312
  if (action2 && action2.showNotification) {
8309
8313
  lastId++;
@@ -8312,9 +8316,12 @@ const Notifications = (props) => {
8312
8316
  id,
8313
8317
  action: action2.name
8314
8318
  }));
8315
- setTimeout(() => setOpenedNotifications((notifications2) => notifications2.filter((notification) => notification.id !== id)), liveTimeoutMs);
8319
+ timeouts.push(setTimeout(() => setOpenedNotifications((notifications2) => notifications2.filter((notification) => notification.id !== id)), liveTimeoutMs));
8316
8320
  }
8317
8321
  }));
8322
+ onCleanup(() => {
8323
+ timeouts.forEach(clearTimeout);
8324
+ });
8318
8325
  return (() => {
8319
8326
  const _el$ = _tmpl$$4.cloneNode(true);
8320
8327
  insert(_el$, createComponent(TransitionGroup, {
@@ -11167,6 +11174,20 @@ function subscribeToThemeChange(callback) {
11167
11174
  window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", handler);
11168
11175
  return () => window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change", handler);
11169
11176
  }
11177
+ function addQueryParameter(url, key, value) {
11178
+ const parsed = new URL(url);
11179
+ parsed.searchParams.append(key, value);
11180
+ return parsed.toString();
11181
+ }
11182
+ function addReturnStrategy(url, returnStrategy) {
11183
+ return addQueryParameter(url, "ret", returnStrategy);
11184
+ }
11185
+ const [appState, setAppState] = createStore({
11186
+ buttonRootId: null,
11187
+ language: "en",
11188
+ returnStrategy: "back",
11189
+ walletsList: {}
11190
+ });
11170
11191
  const QrCodeModal = (props) => {
11171
11192
  const connector = useContext(ConnectorContext);
11172
11193
  const universalLink = connector.connect({
@@ -11217,7 +11238,7 @@ const QrCodeModal = (props) => {
11217
11238
  setLastSelectedWalletInfo(__spreadProps(__spreadValues({}, props.wallet), {
11218
11239
  openMethod: "universal-link"
11219
11240
  }));
11220
- openLink(universalLink);
11241
+ openLink(addReturnStrategy(universalLink, appState.returnStrategy));
11221
11242
  },
11222
11243
  get children() {
11223
11244
  return createComponent(Translation, {
@@ -11457,11 +11478,6 @@ const LoaderContainerStyled = styled.div`
11457
11478
  align-items: center;
11458
11479
  }
11459
11480
  `;
11460
- const [appState, setAppState] = createStore({
11461
- buttonRootId: null,
11462
- language: "en",
11463
- walletsList: {}
11464
- });
11465
11481
  function uiWalletToWalletInfo(uiWallet) {
11466
11482
  if ("jsBridgeKey" in uiWallet) {
11467
11483
  return __spreadProps(__spreadValues({}, uiWallet), {
@@ -11565,14 +11581,14 @@ const WalletsModal = () => {
11565
11581
  setSelectedWalletInfo(walletInfo);
11566
11582
  return;
11567
11583
  }
11568
- openLink(walletInfo.aboutUrl, "_blank");
11584
+ openLinkBlank(walletInfo.aboutUrl);
11569
11585
  };
11570
11586
  const onSelectIfMobile = (walletInfo) => {
11571
11587
  const universalLink = connector.connect({
11572
11588
  universalLink: walletInfo.universalLink,
11573
11589
  bridgeUrl: walletInfo.bridgeUrl
11574
11590
  }, additionalRequest());
11575
- openLink(universalLink);
11591
+ openLink(addReturnStrategy(universalLink, appState.returnStrategy));
11576
11592
  };
11577
11593
  const onSelectIfInjected = (walletInfo) => {
11578
11594
  connector.connect({
@@ -11962,8 +11978,11 @@ class TonConnectUI {
11962
11978
  setBorderRadius(options.uiPreferences.borderRadius);
11963
11979
  }
11964
11980
  setAppState((state) => {
11981
+ var _a2;
11965
11982
  const merged = mergeOptions(
11966
- __spreadValues(__spreadValues({}, options.language && { language: options.language }), !!options.walletsList && { walletsList: options.walletsList }),
11983
+ __spreadValues(__spreadValues(__spreadValues({}, options.language && { language: options.language }), !!((_a2 = options.actionsConfiguration) == null ? void 0 : _a2.returnStrategy) && {
11984
+ returnStrategy: options.actionsConfiguration.returnStrategy
11985
+ }), !!options.walletsList && { walletsList: options.walletsList }),
11967
11986
  unwrap(state)
11968
11987
  );
11969
11988
  if (options.buttonRootId !== void 0) {
@@ -12015,6 +12034,7 @@ class TonConnectUI {
12015
12034
  });
12016
12035
  }
12017
12036
  disconnect() {
12037
+ widgetController.clearAction();
12018
12038
  this.walletInfoStorage.removeWalletInfo();
12019
12039
  return this.connector.disconnect();
12020
12040
  }
@@ -12023,10 +12043,10 @@ class TonConnectUI {
12023
12043
  if (!this.connected || !this.walletInfo) {
12024
12044
  throw new TonConnectUIError("Connect wallet to send a transaction.");
12025
12045
  }
12046
+ const { notifications: notifications2, modals, returnStrategy } = this.getModalsAndNotificationsConfiguration(options);
12026
12047
  if ("universalLink" in this.walletInfo && this.walletInfo.openMethod === "universal-link") {
12027
- openLink(this.walletInfo.universalLink);
12048
+ openLink(addReturnStrategy(this.walletInfo.universalLink, returnStrategy));
12028
12049
  }
12029
- const { notifications: notifications2, modals } = this.getModalsAndNotificationsConfiguration(options);
12030
12050
  widgetController.setAction({
12031
12051
  name: "confirm-transaction",
12032
12052
  showNotification: notifications2.includes("before"),
@@ -12125,7 +12145,8 @@ class TonConnectUI {
12125
12145
  }
12126
12146
  return {
12127
12147
  notifications: notifications2,
12128
- modals
12148
+ modals,
12149
+ returnStrategy: (options == null ? void 0 : options.returnStrategy) || "back"
12129
12150
  };
12130
12151
  }
12131
12152
  }