@types/telegram-web-app 6.9.4 → 7.1.0

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.
@@ -8,7 +8,7 @@ This package contains type definitions for telegram-web-app (https://telegram.or
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/telegram-web-app.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Tue, 30 Jan 2024 21:35:45 GMT
11
+ * Last updated: Wed, 06 Mar 2024 06:35:45 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
@@ -100,6 +100,11 @@ interface WebApp {
100
100
  * bottom of the Web App in the Telegram interface.
101
101
  */
102
102
  MainButton: MainButton;
103
+ /**
104
+ * An object for controlling the Settings item in the context menu of the Mini App
105
+ * in the Telegram interface.
106
+ */
107
+ SettingsButton: SettingsButton;
103
108
  /**
104
109
  * An object for controlling haptic feedback.
105
110
  */
@@ -152,7 +157,7 @@ interface WebApp {
152
157
  eventType: "writeAccessRequested",
153
158
  eventHandler: (eventData: { status: "allowed" | "cancelled" }) => void,
154
159
  ): void;
155
- onEvent(eventType: "contactRequested", eventHandler: (eventData: { status: "sent" | "cancelled" }) => void): void;
160
+ onEvent(eventType: "contactRequested", eventHandler: (eventData: RequestContactResponse) => void): void;
156
161
 
157
162
  /** A method that deletes a previously set event handler. */
158
163
  offEvent(
@@ -171,7 +176,7 @@ interface WebApp {
171
176
  eventType: "writeAccessRequested",
172
177
  eventHandler: (eventData: { status: "allowed" | "cancelled" }) => void,
173
178
  ): void;
174
- offEvent(eventType: "contactRequested", eventHandler: (eventData: { status: "sent" | "cancelled" }) => void): void;
179
+ offEvent(eventType: "contactRequested", eventHandler: (eventData: RequestContactResponse) => void): void;
175
180
 
176
181
  /**
177
182
  * A method used to send data to the bot. When this method is called, a
@@ -234,7 +239,7 @@ interface WebApp {
234
239
  * popup is closed and the first argument will be a boolean indicating whether the user
235
240
  * pressed the 'OK' button.
236
241
  */
237
- showConfirm(message: string, callback?: (ok?: boolean) => void): void;
242
+ showConfirm(message: string, callback?: (ok: boolean) => void): void;
238
243
  /**
239
244
  * A method that shows a native popup for scanning a QR code described by the params argument of the type ScanQrPopupParams.
240
245
  * The Web App will receive the event qrTextReceived every time the scanner catches a code with text data.
@@ -273,9 +278,12 @@ interface WebApp {
273
278
  * @param callback If an optional callback parameter was passed, the
274
279
  * callback function will be called when the popup is closed and the first
275
280
  * argument will be a boolean indicating whether the user shared its
276
- * phone number.
281
+ * phone number. The second argument, contingent upon success, will be
282
+ * an object detailing the shared contact information or a cancellation response.
277
283
  */
278
- requestContact(callback?: (success: boolean) => void): void;
284
+ requestContact(
285
+ callback?: (success: boolean, response: RequestContactResponse) => void,
286
+ ): void;
279
287
  /**
280
288
  * A method that informs the Telegram app that the Web App is ready to be
281
289
  * displayed. It is recommended to call this method as early as possible, as
@@ -302,40 +310,71 @@ interface WebApp {
302
310
  */
303
311
  interface ThemeParams {
304
312
  /**
305
- * Background color in the #RRGGBB format. Also available as the CSS variable
306
- * var(--tg-theme-bg-color).
313
+ * Background color in the `#RRGGBB` format.
314
+ * Also available as the CSS variable `var(--tg-theme-bg-color)`.
315
+ */
316
+ bg_color?: string;
317
+ /**
318
+ * Main text color in the `#RRGGBB` format.
319
+ * Also available as the CSS variable `var(--tg-theme-text-color)`.
320
+ */
321
+ text_color?: string;
322
+ /**
323
+ * Hint text color in the `#RRGGBB` format.
324
+ * Also available as the CSS variable `var(--tg-theme-hint-color)`.
325
+ */
326
+ hint_color?: string;
327
+ /**
328
+ * Link color in the `#RRGGBB` format.
329
+ * Also available as the CSS variable `var(--tg-theme-link-color)`.
330
+ */
331
+ link_color?: string;
332
+ /**
333
+ * Button color in the `#RRGGBB` format.
334
+ * Also available as the CSS variable `var(--tg-theme-button-color)`.
335
+ */
336
+ button_color?: string;
337
+ /**
338
+ * Button text color in the `#RRGGBB` format.
339
+ * Also available as the CSS variable `var(--tg-theme-button-text-color)`.
340
+ */
341
+ button_text_color?: string;
342
+ /**
343
+ * **Bot API 6.1+** Secondary background color in the `#RRGGBB` format.
344
+ * Also available as the CSS variable `var(--tg-theme-secondary-bg-color)`.
307
345
  */
308
- bg_color: string;
346
+ secondary_bg_color?: string;
309
347
  /**
310
- * Main text color in the #RRGGBB format. Also available as the CSS variable
311
- * var(--tg-theme-text-color).
348
+ * **Bot API 7.0+** Header background color in the `#RRGGBB` format.
349
+ * Also available as the CSS variable `var(--tg-theme-header-bg-color)`.
312
350
  */
313
- text_color: string;
351
+ header_bg_color?: string;
314
352
  /**
315
- * Hint text color in the #RRGGBB format. Also available as the CSS variable
316
- * var(--tg-theme-hint-color).
353
+ * **Bot API 7.0+** Accent text color in the `#RRGGBB` format.
354
+ * Also available as the CSS variable `var(--tg-theme-accent-text-color)`.
317
355
  */
318
- hint_color: string;
356
+ accent_text_color?: string;
319
357
  /**
320
- * Link color in the #RRGGBB format. Also available as the CSS variable
321
- * var(--tg-theme-link-color).
358
+ * **Bot API 7.0+** Background color for the section in the `#RRGGBB` format. It is
359
+ * recommended to use this in conjunction with *secondary_bg_color*.
360
+ * Also available as the CSS variable `var(--tg-theme-section-bg-color)`.
322
361
  */
323
- link_color: string;
362
+ section_bg_color?: string;
324
363
  /**
325
- * Button color in the #RRGGBB format. Also available as the CSS variable
326
- * var(--tg-theme-button-color).
364
+ * **Bot API 7.0+** Header text color for the section in the `#RRGGBB` format.
365
+ * Also available as the CSS variable `var(--tg-theme-section-header-text-color)`.
327
366
  */
328
- button_color: string;
367
+ section_header_text_color?: `#${string}`;
329
368
  /**
330
- * Button text color in the #RRGGBB format. Also available as the CSS variable
331
- * var(--tg-theme-button-text-color).
369
+ * **Bot API 7.0+** Subtitle text color in the `#RRGGBB` format.
370
+ * Also available as the CSS variable `var(--tg-theme-subtitle-text-color)`.
332
371
  */
333
- button_text_color: string;
372
+ subtitle_text_color?: string;
334
373
  /**
335
- * Optional. Bot API 6.1+ Secondary background color in the #RRGGBB format.
336
- * Also available as the CSS variable var(--tg-theme-secondary-bg-color).
374
+ * **Bot API 7.0+** Text color for destructive actions in the `#RRGGBB` format.
375
+ * Also available as the CSS variable `var(--tg-theme-destructive-text-color)`.
337
376
  */
338
- secondary_bg_color: string;
377
+ destructive_text_color?: string;
339
378
  }
340
379
 
341
380
  /**
@@ -496,6 +535,37 @@ interface MainButtonParams {
496
535
  is_visible?: boolean;
497
536
  }
498
537
 
538
+ /**
539
+ * This object controls the Settings item in the context menu of the Mini App in the
540
+ * Telegram interface.
541
+ */
542
+ interface SettingsButton {
543
+ /**
544
+ * Shows whether the context menu item is visible. Set to false by default.
545
+ */
546
+ isVisible: boolean;
547
+ /**
548
+ * **Bot API 7.0+** A method that sets the press event handler for the Settings item in
549
+ * the context menu. An alias for
550
+ * `Telegram.WebApp.onEvent('settingsButtonClicked', callback)`
551
+ */
552
+ onClick(callback: () => void): SettingsButton;
553
+ /**
554
+ * **Bot API 7.0+** A method that removes the press event handler from the Settings item
555
+ * in the context menu. An alias for
556
+ * `Telegram.WebApp.offEvent('settingsButtonClicked', callback)`
557
+ */
558
+ offClick(callback: () => void): SettingsButton;
559
+ /**
560
+ * **Bot API 7.0+** A method to make the Settings item in the context menu visible.
561
+ */
562
+ show(): SettingsButton;
563
+ /**
564
+ * **Bot API 7.0+** A method to hide the Settings item in the context menu.
565
+ */
566
+ hide(): SettingsButton;
567
+ }
568
+
499
569
  /**
500
570
  * This object controls haptic feedback.
501
571
  */
@@ -742,3 +812,43 @@ interface ScanQrPopupParams {
742
812
  */
743
813
  text?: string;
744
814
  }
815
+
816
+ /**
817
+ * This object describes contact information shared when requestContact was approved by the user.
818
+ */
819
+ interface RequestContactResponseSent {
820
+ /** Status 'sent' indicates that contact information has been shared. */
821
+ status: "sent";
822
+ /** A status message or result as a string. */
823
+ response: string;
824
+ /** Contains sensitive information shared upon user consent. WARNING: Data from
825
+ * this field should not be trusted. You should only use data from `response` on
826
+ * the bot's server and only after it has been validated. */
827
+ responseUnsafe: {
828
+ /** Authorization date for sharing contact information. */
829
+ auth_date: string;
830
+ /** Object holding user's contact details. */
831
+ contact: {
832
+ /** User's first name. */
833
+ first_name: string;
834
+ /** Optional. User's last name. */
835
+ last_name?: string;
836
+ /** User's phone number. */
837
+ phone_number: string;
838
+ /** Unique identifier of the user. */
839
+ user_id: number;
840
+ };
841
+ /** Hash to verify data authenticity. */
842
+ hash: string;
843
+ };
844
+ }
845
+
846
+ /**
847
+ * This object only contains a status to indicate the cancellation.
848
+ */
849
+ interface RequestContactResponseCancelled {
850
+ /** Status 'cancelled', indicates that user cancelled the contact share request. */
851
+ status: "cancelled";
852
+ }
853
+
854
+ type RequestContactResponse = RequestContactResponseSent | RequestContactResponseCancelled;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/telegram-web-app",
3
- "version": "6.9.4",
3
+ "version": "7.1.0",
4
4
  "description": "TypeScript definitions for telegram-web-app",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/telegram-web-app",
6
6
  "license": "MIT",
@@ -30,6 +30,6 @@
30
30
  },
31
31
  "scripts": {},
32
32
  "dependencies": {},
33
- "typesPublisherContentHash": "f70f23a3b990dc2c535e121fd523ee59fc5f4bdbb0a14704a789480711a9a8ed",
33
+ "typesPublisherContentHash": "e60f7c8652216a4904f9dec0fa735f121014abd943bd6a19bb9c430198c076b6",
34
34
  "typeScriptVersion": "4.6"
35
35
  }