From 339650c1d9211b9835e4292e104e5e8aea62c928 Mon Sep 17 00:00:00 2001 From: DmitryDavis Date: Mon, 22 Jan 2024 20:50:20 +0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=BD=EF=B8=8F=20Add=20typings=20for=20B?= =?UTF-8?q?OT=20API=207.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- package.json | 2 +- src/index.d.ts | 84 +++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 85 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6a42a9b..b69a208 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ npm

-Telegram Bot API Version 6.9 +Telegram Bot API Version 7.0

CI Lint diff --git a/package.json b/package.json index eec016a..d748f0a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "telegram-webapps", - "version": "6.9.0", + "version": "7.0.0", "description": "Typings for Telegram Web Apps", "keywords": [ "telegram", diff --git a/src/index.d.ts b/src/index.d.ts index ddb78b1..fa9562a 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -68,7 +68,16 @@ export declare namespace TelegramWebApps { /** * The name of the platform of the user's Telegram app. */ - readonly platform: string + readonly platform: + | 'android' + | 'android_x' + | 'ios' + | 'macos' + | 'tdesktop' + | 'weba' + | 'webk' + | 'unigram' + | 'unknown' /** * The color scheme currently used in the Telegram app. * @@ -142,6 +151,11 @@ export declare namespace TelegramWebApps { * Web App in the Telegram interface. */ readonly MainButton: MainButton + /** + * An object for controlling the Settings item in the context menu of the Mini App in + * the Telegram interface. + */ + readonly SettingsButton: SettingsButton /** * An object for controlling haptic feedback. */ @@ -509,6 +523,43 @@ export declare namespace TelegramWebApps { * Also available as the CSS variable `var(--tg-theme-secondary-bg-color)`. */ secondary_bg_color?: string + /** + * `Bot API 7.0+` Header background color in the `#RRGGBB` format. + * + * Also available as the CSS variable `var(--tg-theme-header-bg-color)`. + */ + header_bg_color?: string + /** + * `Bot API 7.0+` Accent text color in the `#RRGGBB` format. + * + * Also available as the CSS variable `var(--tg-theme-accent-text-color)`. + */ + accent_text_color?: string + /** + * `Bot API 7.0+` Background color for the section in the `#RRGGBB` format. It is + * recommended to use this in conjunction with *secondary_bg_color*. + * + * Also available as the CSS variable `var(--tg-theme-section-bg-color)`. + */ + section_bg_color?: string + /** + * `Bot API 7.0+` Header text color for the section in the `#RRGGBB` format. + * + * Also available as the CSS variable `var(--tg-theme-section-header-text-color)`. + */ + section_header_text_color?: `#${string}` + /** + * `Bot API 7.0+` Subtitle text color in the `#RRGGBB` format. + * + * Also available as the CSS variable `var(--tg-theme-subtitle-text-color)`. + */ + subtitle_text_color?: string + /** + * `Bot API 7.0+` Text color for destructive actions in the `#RRGGBB` format. + * + * Also available as the CSS variable `var(--tg-theme-destructive-text-color)`. + */ + destructive_text_color?: string } /** @@ -672,6 +723,37 @@ export declare namespace TelegramWebApps { }): MainButton } + /** + * This object controls the Settings item in the context menu of the Mini App in the + * Telegram interface. + */ + interface SettingsButton { + /** + * Shows whether the context menu item is visible. Set to **false** by default. + */ + isVisible: boolean + /** + * `Bot API 7.0+` A method that sets the press event handler for the Settings item in + * the context menu. An alias for + * `Telegram.WebApp.onEvent('settingsButtonClicked', callback)` + */ + onClick(callback: () => void): SettingsButton + /** + * `Bot API 7.0+` A method that removes the press event handler from the Settings item + * in the context menu. An alias for + * `Telegram.WebApp.offEvent('settingsButtonClicked', callback)` + */ + offClick(callback: () => void): SettingsButton + /** + * `Bot API 7.0+` A method to make the Settings item in the context menu visible. + */ + show(): SettingsButton + /** + * `Bot API 7.0+` A method to hide the Settings item in the context menu. + */ + hide(): SettingsButton + } + /** * This object controls haptic feedback. */