tg-screen
Version:
Declarative telegram mini app screen
64 lines (63 loc) • 2.42 kB
TypeScript
import React from 'react';
import { PropsWithChildren } from 'react';
import { MainButtonState, SecondaryButtonState } from '@telegram-apps/sdk-react';
/**
* Before Use you need to manually mount appropriate components from
* telegram-apps sdk-react
*
* https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk/2-x/usage-tips#mount-used-components
*/
export declare function TgScreen({ children, mainButtonProps, secondaryButtonProps, onBack, onSettings, closeConfirmation, autoExpand, allowSwipeExpand, backgroundColor, headerColor, bottomBarColor, silentErrors, }: PropsWithChildren<{
/**
* https://docs.telegram-mini-apps.com/platform/methods#web-app-setup-main-button
*/
mainButtonProps?: {
onClick: () => void;
} & Omit<Partial<MainButtonState>, "isVisible">;
/**
* https://docs.telegram-mini-apps.com/platform/methods#web-app-setup-secondary-button
*/
secondaryButtonProps?: {
onClick: () => void;
} & Omit<Partial<SecondaryButtonState>, "isVisible">;
onBack?: () => void;
onSettings?: () => void;
/**
* Defines if the confirmation dialog should be shown when user tries to close the screen
* @default true
*/
closeConfirmation?: boolean;
/**
* Defines if the screen should be expanded by default
* @default true
*/
autoExpand?: boolean;
/**
* If true, allows to expand or close the screen by swiping vertically
* @default true
*/
allowSwipeExpand?: boolean;
/**
* Can be eather RGB color or allowed theme color_key:
* https://docs.telegram-mini-apps.com/platform/methods#web-app-set-background-color
*/
backgroundColor?: string;
/**
* Can be eather RGB color or allowed theme color_key:
* https://docs.telegram-mini-apps.com/platform/methods#web-app-set-header-color
*/
headerColor?: string;
/**
* Can be eather RGB color or allowed theme color_key:
* https://docs.telegram-mini-apps.com/platform/methods#web-app-set-bottom-bar-color
*/
bottomBarColor?: string;
/**
* if false original post evet errors will be thrown
*
* NOTE: if silent true, then overrides postEvent property from mini app sdk init() method:
* https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk/2-x/initializing
* @default true
*/
silentErrors?: boolean;
}>): React.JSX.Element;