Skip to content

Commit

Permalink
👽️ Add typings for BOT API 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisDmitry committed Jan 22, 2024
1 parent 2bac64f commit 339650c
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<a href="https://npmjs.com/package/telegram-webapps"><img alt="npm" src="https://img.shields.io/npm/dt/telegram-webapps"/></a>
</p>
<p align="center">
<a href="https://core.telegram.org/bots/webapps"><img alt="Telegram Bot API Version 6.9" src="https://img.shields.io/badge/Telegram%20Bot%20API-6.9-blue.svg?logo=telegram"/></a>
<a href="https://core.telegram.org/bots/webapps"><img alt="Telegram Bot API Version 7.0" src="https://img.shields.io/badge/Telegram%20Bot%20API-7.0-blue.svg?logo=telegram"/></a>
</p>
<p align="center">
<a href="https://github.com/DavisDmitry/telegram-webapps/actions/workflows/lint.yml"><img alt="CI Lint" src="https://github.com/DavisDmitry/telegram-webapps/actions/workflows/lint.yml/badge.svg"/></a>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "telegram-webapps",
"version": "6.9.0",
"version": "7.0.0",
"description": "Typings for Telegram Web Apps",
"keywords": [
"telegram",
Expand Down
84 changes: 83 additions & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
}

/**
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit 339650c

Please sign in to comment.