tguikit 0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vladyslav Skrynnyk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # tguikit
2
+
3
+ React 19 component library for Telegram Mini Apps — a modern reimplementation of [`@telegram-apps/telegram-ui`](https://github.com/telegram-mini-apps-dev/TelegramUI).
4
+
5
+ **[Storybook →](https://alwaysgladtobethefirst.github.io/tgui/)**
6
+
7
+ > Pre-release. The API is still moving before `1.0`.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ bun add tguikit
13
+ ```
14
+
15
+ `react` and `react-dom` 19 are peer dependencies.
16
+
17
+ ## Use
18
+
19
+ ```tsx
20
+ import { TguiProvider, Button } from 'tguikit';
21
+ import 'tguikit/styles.css';
22
+
23
+ export function App() {
24
+ return (
25
+ <TguiProvider>
26
+ <Button mode="filled" size="l" stretched>
27
+ Continue
28
+ </Button>
29
+ </TguiProvider>
30
+ );
31
+ }
32
+ ```
33
+
34
+ `TguiProvider` supplies the theme and platform. It follows the Telegram / system light–dark theme automatically; pass `appearance` or `platform` to pin them.
35
+
36
+ ## What it fixes
37
+
38
+ See [`IMPROVEMENTS.md`](./IMPROVEMENTS.md) — ref forwarding, theme tokens, touch-safe hover, SSR, a real package build, and a bundle roughly a tenth the size of the original.
39
+
40
+ ## Develop
41
+
42
+ ```bash
43
+ bun install
44
+ bun run storybook
45
+ ```
46
+
47
+ Storybook is the workbench — every component has a story. The hosted build is at
48
+ [alwaysgladtobethefirst.github.io/tgui](https://alwaysgladtobethefirst.github.io/tgui/).
49
+
50
+ See [`CONTRIBUTING.md`](./CONTRIBUTING.md).
51
+
52
+ ## License
53
+
54
+ MIT
@@ -0,0 +1,279 @@
1
+ import * as react from 'react';
2
+ import { AllHTMLAttributes, Ref, ElementType, ReactNode, HTMLAttributes, InputHTMLAttributes, SelectHTMLAttributes, ButtonHTMLAttributes } from 'react';
3
+
4
+ type TguiPlatform = 'ios' | 'base';
5
+ type Appearance = 'light' | 'dark';
6
+ interface TguiContextValue {
7
+ platform: TguiPlatform;
8
+ appearance: Appearance;
9
+ portalContainer: HTMLElement | null;
10
+ }
11
+
12
+ type ButtonMode = 'filled' | 'bezeled' | 'plain' | 'gray' | 'outline' | 'white';
13
+ type ButtonSize = 's' | 'm' | 'l';
14
+
15
+ interface ButtonProps extends Omit<AllHTMLAttributes<HTMLElement>, 'size'> {
16
+ ref?: Ref<HTMLElement>;
17
+ Component?: ElementType;
18
+ mode?: ButtonMode;
19
+ size?: ButtonSize;
20
+ stretched?: boolean;
21
+ loading?: boolean;
22
+ before?: ReactNode;
23
+ after?: ReactNode;
24
+ }
25
+ declare function Button({ ref, Component, mode, size, stretched, loading, type, before, after, children, className, ...rest }: ButtonProps): react.JSX.Element;
26
+ declare namespace Button {
27
+ var displayName: string;
28
+ }
29
+
30
+ interface TypographyProps extends AllHTMLAttributes<HTMLElement> {
31
+ ref?: Ref<HTMLElement>;
32
+ weight?: '1' | '2' | '3';
33
+ caps?: boolean;
34
+ Component?: ElementType;
35
+ }
36
+ declare function Typography({ ref, weight, caps, Component, className, ...rest }: TypographyProps): react.JSX.Element;
37
+ declare namespace Typography {
38
+ var displayName: string;
39
+ }
40
+
41
+ type CaptionLevel = '1' | '2';
42
+
43
+ interface CaptionProps extends TypographyProps {
44
+ ref?: Ref<HTMLElement>;
45
+ level?: CaptionLevel;
46
+ }
47
+ declare function Caption({ ref, level, Component, className, ...rest }: CaptionProps): react.JSX.Element;
48
+ declare namespace Caption {
49
+ var displayName: string;
50
+ }
51
+
52
+ type CardType = 'plain' | 'ambient';
53
+
54
+ interface TappableProps extends AllHTMLAttributes<HTMLElement> {
55
+ ref?: Ref<HTMLElement>;
56
+ Component?: ElementType;
57
+ interactiveAnimation?: 'background' | 'opacity';
58
+ }
59
+ declare function Tappable({ ref, Component, interactiveAnimation, className, children, onPointerDown, onPointerCancel, ...rest }: TappableProps): react.JSX.Element;
60
+ declare namespace Tappable {
61
+ var displayName: string;
62
+ }
63
+
64
+ interface CellProps extends Omit<TappableProps, 'Component'> {
65
+ ref?: Ref<HTMLElement>;
66
+ Component?: ElementType;
67
+ subhead?: ReactNode;
68
+ hint?: ReactNode;
69
+ titleBadge?: ReactNode;
70
+ subtitle?: ReactNode;
71
+ description?: ReactNode;
72
+ before?: ReactNode;
73
+ after?: ReactNode;
74
+ hovered?: boolean;
75
+ multiline?: boolean;
76
+ }
77
+ declare function Cell({ ref, Component, subhead, children, hint, titleBadge, subtitle, description, before, after, hovered, multiline, className, ...rest }: CellProps): react.JSX.Element;
78
+ declare namespace Cell {
79
+ var displayName: string;
80
+ }
81
+
82
+ interface CardCellProps extends CellProps {
83
+ ref?: Ref<HTMLElement>;
84
+ }
85
+ declare function CardCell({ ref, children, subtitle, className, ...rest }: CardCellProps): react.JSX.Element;
86
+ declare namespace CardCell {
87
+ var displayName: string;
88
+ }
89
+
90
+ interface CardProps extends HTMLAttributes<HTMLElement> {
91
+ ref?: Ref<HTMLElement>;
92
+ type?: CardType;
93
+ }
94
+ declare function Card({ ref, type, className, children, ...rest }: CardProps): react.JSX.Element;
95
+ declare namespace Card {
96
+ var displayName: string;
97
+ var Cell: typeof CardCell;
98
+ }
99
+
100
+ interface CheckboxProps extends InputHTMLAttributes<HTMLInputElement> {
101
+ ref?: Ref<HTMLInputElement>;
102
+ indeterminate?: boolean;
103
+ }
104
+ declare function Checkbox({ ref, indeterminate, disabled, className, style, ...rest }: CheckboxProps): react.JSX.Element;
105
+ declare namespace Checkbox {
106
+ var displayName: string;
107
+ }
108
+
109
+ interface DividerProps extends HTMLAttributes<HTMLHRElement> {
110
+ ref?: Ref<HTMLHRElement>;
111
+ }
112
+ declare function Divider({ ref, className, ...rest }: DividerProps): react.JSX.Element;
113
+ declare namespace Divider {
114
+ var displayName: string;
115
+ }
116
+
117
+ interface HeadlineProps extends TypographyProps {
118
+ ref?: Ref<HTMLElement>;
119
+ }
120
+ declare function Headline({ ref, weight, className, Component, ...rest }: HeadlineProps): react.JSX.Element;
121
+ declare namespace Headline {
122
+ var displayName: string;
123
+ }
124
+
125
+ type InputStatus = 'default' | 'error' | 'focused';
126
+ interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
127
+ ref?: Ref<HTMLInputElement>;
128
+ header?: ReactNode;
129
+ before?: ReactNode;
130
+ after?: ReactNode;
131
+ status?: InputStatus;
132
+ }
133
+ declare function Input({ ref, type, header, before, after, status, disabled, className, onFocus, onBlur, ...rest }: InputProps): react.JSX.Element;
134
+ declare namespace Input {
135
+ var displayName: string;
136
+ }
137
+
138
+ interface LargeTitleProps extends TypographyProps {
139
+ ref?: Ref<HTMLElement>;
140
+ }
141
+ declare function LargeTitle({ ref, weight, className, Component, ...rest }: LargeTitleProps): react.JSX.Element;
142
+ declare namespace LargeTitle {
143
+ var displayName: string;
144
+ }
145
+
146
+ interface ListProps extends HTMLAttributes<HTMLElement> {
147
+ ref?: Ref<HTMLElement>;
148
+ Component?: ElementType;
149
+ }
150
+ declare function List({ ref, Component, className, children, ...rest }: ListProps): react.JSX.Element;
151
+ declare namespace List {
152
+ var displayName: string;
153
+ }
154
+
155
+ interface PlaceholderProps extends HTMLAttributes<HTMLElement> {
156
+ ref?: Ref<HTMLElement>;
157
+ children?: ReactNode;
158
+ header?: ReactNode;
159
+ description?: ReactNode;
160
+ action?: ReactNode;
161
+ }
162
+ declare function Placeholder({ ref, children, header, description, action, className, ...rest }: PlaceholderProps): react.JSX.Element;
163
+ declare namespace Placeholder {
164
+ var displayName: string;
165
+ }
166
+
167
+ interface SectionFooterProps extends HTMLAttributes<HTMLElement> {
168
+ ref?: Ref<HTMLElement>;
169
+ centered?: boolean;
170
+ }
171
+ declare function SectionFooter({ ref, centered, className, children, ...rest }: SectionFooterProps): react.JSX.Element;
172
+ declare namespace SectionFooter {
173
+ var displayName: string;
174
+ }
175
+
176
+ interface SectionHeaderProps extends HTMLAttributes<HTMLElement> {
177
+ ref?: Ref<HTMLElement>;
178
+ large?: boolean;
179
+ }
180
+ declare function SectionHeader({ ref, large, className, children, ...rest }: SectionHeaderProps): react.JSX.Element;
181
+ declare namespace SectionHeader {
182
+ var displayName: string;
183
+ }
184
+
185
+ interface SectionProps extends HTMLAttributes<HTMLElement> {
186
+ ref?: Ref<HTMLElement>;
187
+ header?: ReactNode;
188
+ footer?: ReactNode;
189
+ }
190
+ declare function Section({ ref, header, footer, className, children, ...rest }: SectionProps): react.JSX.Element;
191
+ declare namespace Section {
192
+ var displayName: string;
193
+ var Header: typeof SectionHeader;
194
+ var Footer: typeof SectionFooter;
195
+ }
196
+
197
+ interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
198
+ ref?: Ref<HTMLSelectElement>;
199
+ header?: ReactNode;
200
+ status?: InputStatus;
201
+ }
202
+ declare function Select({ ref, header, status, disabled, className, onFocus, onBlur, children, ...rest }: SelectProps): react.JSX.Element;
203
+ declare namespace Select {
204
+ var displayName: string;
205
+ }
206
+
207
+ type SubheadlineLevel = '1' | '2';
208
+
209
+ interface SubheadlineProps extends TypographyProps {
210
+ ref?: Ref<HTMLElement>;
211
+ level?: SubheadlineLevel;
212
+ }
213
+ declare function Subheadline({ ref, level, Component, className, ...rest }: SubheadlineProps): react.JSX.Element;
214
+ declare namespace Subheadline {
215
+ var displayName: string;
216
+ }
217
+
218
+ interface SwitchProps extends InputHTMLAttributes<HTMLInputElement> {
219
+ ref?: Ref<HTMLInputElement>;
220
+ }
221
+ declare function Switch({ ref, disabled, className, style, ...rest }: SwitchProps): react.JSX.Element;
222
+ declare namespace Switch {
223
+ var displayName: string;
224
+ }
225
+
226
+ interface TabBarItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {
227
+ ref?: Ref<HTMLElement>;
228
+ selected?: boolean;
229
+ text?: string;
230
+ children?: ReactNode;
231
+ }
232
+ declare function TabBarItem({ ref, selected, text, children, className, ...rest }: TabBarItemProps): react.JSX.Element;
233
+ declare namespace TabBarItem {
234
+ var displayName: string;
235
+ }
236
+
237
+ interface TabBarProps extends HTMLAttributes<HTMLElement> {
238
+ ref?: Ref<HTMLElement>;
239
+ }
240
+ declare function TabBar({ ref, className, children, ...rest }: TabBarProps): react.JSX.Element;
241
+ declare namespace TabBar {
242
+ var displayName: string;
243
+ var Item: typeof TabBarItem;
244
+ }
245
+
246
+ interface TextProps extends TypographyProps {
247
+ ref?: Ref<HTMLElement>;
248
+ }
249
+ declare function Text({ ref, className, Component, ...rest }: TextProps): react.JSX.Element;
250
+ declare namespace Text {
251
+ var displayName: string;
252
+ }
253
+
254
+ interface TguiProviderProps extends HTMLAttributes<HTMLDivElement> {
255
+ ref?: Ref<HTMLDivElement>;
256
+ platform?: TguiPlatform;
257
+ appearance?: Appearance;
258
+ portalContainer?: HTMLElement | null;
259
+ }
260
+ declare function TguiProvider({ ref, platform: platformProp, appearance: appearanceProp, portalContainer: portalContainerProp, className, children, ...rest }: TguiProviderProps): react.JSX.Element;
261
+ declare namespace TguiProvider {
262
+ var displayName: string;
263
+ }
264
+
265
+ declare function useTgui(): TguiContextValue;
266
+
267
+ type TitleLevel = '1' | '2' | '3';
268
+
269
+ interface TitleProps extends TypographyProps {
270
+ ref?: Ref<HTMLElement>;
271
+ level?: TitleLevel;
272
+ }
273
+ declare function Title({ ref, level, Component, className, ...rest }: TitleProps): react.JSX.Element;
274
+ declare namespace Title {
275
+ var displayName: string;
276
+ }
277
+
278
+ export { Button, Caption, Card, CardCell, Cell, Checkbox, Divider, Headline, Input, LargeTitle, List, Placeholder, Section, SectionFooter, SectionHeader, Select, Subheadline, Switch, TabBar, TabBarItem, Tappable, Text, TguiProvider, Title, Typography, useTgui };
279
+ export type { ButtonMode, ButtonProps, ButtonSize, CaptionProps, CardCellProps, CardProps, CardType, CellProps, CheckboxProps, DividerProps, HeadlineProps, InputProps, InputStatus, LargeTitleProps, ListProps, PlaceholderProps, SectionFooterProps, SectionHeaderProps, SectionProps, SelectProps, SubheadlineProps, SwitchProps, TabBarItemProps, TabBarProps, TappableProps, TextProps, TguiProviderProps, TitleProps, TypographyProps };