@tonconnect/ui 0.0.7 → 0.0.9

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.d.ts CHANGED
@@ -1,62 +1,136 @@
1
- import { WalletConnectionSource, ITonConnect, WalletInfo, Account, Wallet, TonConnectError, SendTransactionRequest, SendTransactionResponse } from '@tonconnect/sdk';
1
+ import { WalletInfoBase, WalletInfoInjected, WalletInfoRemote, ITonConnect, WalletInfo, Account, Wallet, TonConnectError, SendTransactionRequest, SendTransactionResponse } from '@tonconnect/sdk';
2
2
  import { Property } from 'csstype';
3
3
 
4
+ declare type Locales = 'en' | 'ru';
5
+
4
6
  declare enum THEME {
5
7
  DARK = "DARK",
6
8
  LIGHT = "LIGHT"
7
9
  }
8
10
  declare type Theme = THEME | 'SYSTEM';
9
11
 
10
- declare type Color$1 = Property.Color;
12
+ declare type BorderRadius = 'm' | 's' | 'none';
11
13
 
12
- interface Themed {
13
- theme: Theme;
14
- accentColor: Color$1;
15
- }
14
+ declare type Color$1 = Property.Color;
15
+ declare type ColorsSet = {
16
+ constant: {
17
+ black: Color$1;
18
+ white: Color$1;
19
+ };
20
+ connectButton: {
21
+ background: Color$1;
22
+ foreground: Color$1;
23
+ };
24
+ accent: Color$1;
25
+ icon: {
26
+ primary: Color$1;
27
+ secondary: Color$1;
28
+ tertiary: Color$1;
29
+ success: Color$1;
30
+ };
31
+ background: {
32
+ primary: Color$1;
33
+ secondary: Color$1;
34
+ };
35
+ text: {
36
+ primary: Color$1;
37
+ subhead: Color$1;
38
+ secondary: Color$1;
39
+ };
40
+ };
41
+ declare type PartialColorsSet = {
42
+ constant?: {
43
+ black?: Color$1;
44
+ white?: Color$1;
45
+ };
46
+ connectButton?: {
47
+ background?: Color$1;
48
+ foreground?: Color$1;
49
+ };
50
+ accent?: Color$1;
51
+ icon?: {
52
+ primary?: Color$1;
53
+ secondary?: Color$1;
54
+ tertiary?: Color$1;
55
+ success?: Color$1;
56
+ };
57
+ background?: {
58
+ primary?: Color$1;
59
+ secondary?: Color$1;
60
+ };
61
+ text?: {
62
+ primary?: Color$1;
63
+ subhead?: Color$1;
64
+ secondary?: Color$1;
65
+ };
66
+ };
16
67
 
17
- declare type ButtonSize = 'm' | 'l';
18
- declare type ButtonAppearance = 'primary' | 'secondary' | 'flat';
19
- interface ButtonConfiguration extends Partial<Themed> {
20
- size: ButtonSize;
21
- appearance: ButtonAppearance;
68
+ interface UIPreferences {
69
+ /**
70
+ * Color theme for the UI elements.
71
+ * @default SYSTEM theme.
72
+ */
73
+ theme?: Theme;
74
+ /**
75
+ * Birder radius for UI elements.
76
+ * @default 'm'
77
+ */
78
+ borderRadius?: BorderRadius;
79
+ /**
80
+ * Configure colors scheme for different themes.
81
+ */
82
+ colorsSet?: Partial<Record<THEME, PartialColorsSet>>;
22
83
  }
23
84
 
24
- interface UiWallet {
25
- name: string;
26
- iconUrl: string;
27
- connectionSource: WalletConnectionSource;
28
- }
85
+ declare type UIWallet = WalletInfoBase & (Omit<WalletInfoInjected, 'injected' | 'embedded'> | WalletInfoRemote);
29
86
 
30
87
  declare type WalletsListConfiguration = WalletsListConfigurationExplicit | WalletsListConfigurationImplicit;
88
+ /**
89
+ * Configure whole list of wallets in the modal. Only passed wallets will be displayed.
90
+ */
31
91
  declare type WalletsListConfigurationExplicit = {
32
- wallets: (string | UiWallet)[];
92
+ /**
93
+ * Allows to configure wallets order and add custom wallets. Must be an array of wallets names from WalletsList or custom wallets.
94
+ */
95
+ wallets: (string | UIWallet)[];
33
96
  };
97
+ /**
98
+ * Add corrections to the default wallets list in the modal: exclude some wallets and add custom wallets.
99
+ */
34
100
  declare type WalletsListConfigurationImplicit = {
101
+ /**
102
+ * Allows to exclude wallets from wallets list in the modal by its names. Must be an array of wallet's names from WalletsList.
103
+ */
35
104
  excludeWallets?: string[];
36
- includeWallets?: UiWallet[];
105
+ /**
106
+ * Allows to include extra wallets to the wallets list in the modal.
107
+ */
108
+ includeWallets?: UIWallet[];
109
+ /**
110
+ * Allows to specify order of the extra wallets in the wallets list in the modal. Cannot be applied if `includeWallets` is not specified.
111
+ * @default 'end'.
112
+ */
113
+ includeWalletsOrder?: 'start' | 'end';
37
114
  };
38
115
 
39
- declare type ModalSize = 'm' | 'l';
40
- interface WidgetConfiguration extends Partial<Themed> {
41
- size: ModalSize;
42
- wallets?: WalletsListConfiguration;
116
+ interface ActionConfiguration {
117
+ /**
118
+ * Configure action modals behavior.
119
+ * @default ['before']
120
+ */
121
+ modals?: ('before' | 'success' | 'error')[] | 'all';
122
+ /**
123
+ * Configure action notifications behavior.
124
+ * @default 'all'
125
+ */
126
+ notifications?: ('before' | 'success' | 'error')[] | 'all';
43
127
  }
44
128
 
45
- declare type Locales = 'en' | 'ru';
46
-
47
- declare type Color = Property.Color;
48
-
49
129
  interface TonConnectUiOptions {
50
130
  /**
51
- * Color theme for the UI elements.
52
- * @default SYSTEM theme.
53
- */
54
- theme?: Theme;
55
- /**
56
- * Accent color for the UI elements.
57
- * @default #31A6F5 (blue).
131
+ * UI elements configuration.
58
132
  */
59
- accentColor?: Color;
133
+ uiPreferences?: UIPreferences;
60
134
  /**
61
135
  * HTML element id to attach the wallet connect button. If not passed button won't appear.
62
136
  * @default null.
@@ -68,13 +142,17 @@ interface TonConnectUiOptions {
68
142
  */
69
143
  language?: Locales;
70
144
  /**
71
- * Configuration for the wallet connect button.
145
+ * Configuration for the wallets list in the connect wallet modal.
146
+ */
147
+ walletsList?: WalletsListConfiguration;
148
+ /**
149
+ * Configuration for action-period (e.g. sendTransaction) UI elements: modals and notifications.
72
150
  */
73
- buttonConfiguration?: Partial<ButtonConfiguration>;
151
+ actionsConfiguration?: ActionConfiguration;
74
152
  /**
75
- * Configuration for the wallet connect modal and action modals.
153
+ * @deprecated Don't use it
76
154
  */
77
- widgetConfiguration?: Partial<WidgetConfiguration>;
155
+ walletsListSource?: string;
78
156
  }
79
157
 
80
158
  declare type TonConnectUiCreateOptions = TonConnectUiOptionsWithConnector | TonConnectUiOptionsWithManifest;
@@ -110,6 +188,7 @@ declare class TonConnectUI {
110
188
  private readonly connector;
111
189
  private _walletInfo;
112
190
  private systemThemeChangeUnsubscribe;
191
+ private actionsConfiguration?;
113
192
  /**
114
193
  * Current connection status.
115
194
  */
@@ -154,18 +233,18 @@ declare class TonConnectUI {
154
233
  * @param tx transaction to send.
155
234
  * @param options modal and notifications behaviour settings. Default is show only 'before' modal and all notifications.
156
235
  */
157
- sendTransaction(tx: SendTransactionRequest, options?: {
158
- modals?: ('before' | 'success' | 'error')[];
159
- notifications?: ('before' | 'success' | 'error')[];
160
- }): Promise<SendTransactionResponse>;
236
+ sendTransaction(tx: SendTransactionRequest, options?: ActionConfiguration): Promise<SendTransactionResponse>;
161
237
  private subscribeToWalletChange;
162
238
  private updateWalletInfo;
163
239
  private normalizeWidgetRoot;
164
240
  private checkButtonRootExist;
241
+ private getModalsAndNotificationsConfiguration;
165
242
  }
166
243
 
244
+ declare type Color = Property.Color;
245
+
167
246
  declare class TonConnectUIError extends TonConnectError {
168
247
  constructor(...args: ConstructorParameters<typeof Error>);
169
248
  }
170
249
 
171
- export { ButtonAppearance, ButtonConfiguration, ButtonSize, Locales, THEME, Theme, Themed, TonConnectUI, TonConnectUIError, TonConnectUiCreateOptions, TonConnectUiCreateOptionsBase, TonConnectUiOptions, TonConnectUiOptionsWithConnector, TonConnectUiOptionsWithManifest, WalletsListConfiguration, WalletsListConfigurationExplicit, WalletsListConfigurationImplicit, WidgetConfiguration, TonConnectUI as default };
250
+ export { ActionConfiguration, BorderRadius, Color, ColorsSet, Locales, PartialColorsSet, THEME, Theme, TonConnectUI, TonConnectUIError, TonConnectUiCreateOptions, TonConnectUiCreateOptionsBase, TonConnectUiOptions, TonConnectUiOptionsWithConnector, TonConnectUiOptionsWithManifest, UIPreferences, UIWallet, WalletsListConfiguration, WalletsListConfigurationExplicit, WalletsListConfigurationImplicit, TonConnectUI as default };