@xsolla/xui-button 0.64.0-pr56.1768440195

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.
@@ -0,0 +1,249 @@
1
+ import React, { ReactNode } from 'react';
2
+
3
+ interface ButtonProps {
4
+ /** Visual variant of the button */
5
+ variant?: "primary" | "secondary";
6
+ /** Color tone of the button */
7
+ tone?: "brand" | "brandExtra" | "alert" | "mono";
8
+ /** Size of the button */
9
+ size?: "xl" | "l" | "m" | "s" | "xs";
10
+ /** Whether the button is disabled */
11
+ disabled?: boolean;
12
+ /** Whether the button is in a loading state */
13
+ loading?: boolean;
14
+ /** Button content */
15
+ children: React.ReactNode;
16
+ /** Click handler */
17
+ onPress?: () => void;
18
+ /** Icon to display on the left side */
19
+ iconLeft?: React.ReactNode;
20
+ /** Icon to display on the right side */
21
+ iconRight?: React.ReactNode;
22
+ /** Accessible label for screen readers (defaults to children if string) */
23
+ "aria-label"?: string;
24
+ /** ID of element that describes this button */
25
+ "aria-describedby"?: string;
26
+ /** Indicates the button controls an expandable element */
27
+ "aria-expanded"?: boolean;
28
+ /** Indicates the type of popup triggered by the button */
29
+ "aria-haspopup"?: boolean | "menu" | "listbox" | "tree" | "grid" | "dialog";
30
+ /** Indicates the button is pressed (for toggle buttons) */
31
+ "aria-pressed"?: boolean | "mixed";
32
+ /** ID of the element this button controls */
33
+ "aria-controls"?: string;
34
+ /** Test ID for testing frameworks */
35
+ testID?: string;
36
+ /** HTML id attribute */
37
+ id?: string;
38
+ /** HTML type attribute for the button */
39
+ type?: "button" | "submit" | "reset";
40
+ /** Whether the button should take up the full width of its container */
41
+ fullWidth?: boolean;
42
+ }
43
+ /**
44
+ * Button - An accessible button component
45
+ *
46
+ * Renders as a semantic `<button>` element with full ARIA support.
47
+ * Supports various visual variants, sizes, and states including loading.
48
+ *
49
+ * ## Accessibility Features
50
+ *
51
+ * - **Semantic HTML**: Renders as a native `<button>` element
52
+ * - **Keyboard Navigation**: Focusable via Tab, activated with Enter or Space
53
+ * - **ARIA States**: Properly announces disabled and loading states
54
+ * - **Focus Indicator**: Visible focus ring for keyboard navigation
55
+ * - **Screen Reader Support**: Announces button label, state, and any associated descriptions
56
+ *
57
+ */
58
+ declare const Button: React.FC<ButtonProps>;
59
+
60
+ interface IconButtonProps {
61
+ /** Visual variant of the button */
62
+ variant?: "primary" | "secondary";
63
+ /** Color tone of the button */
64
+ tone?: "brand" | "brandExtra" | "alert" | "mono";
65
+ /** Size of the button */
66
+ size?: "xl" | "l" | "m" | "s" | "xs";
67
+ /** Whether the button is disabled */
68
+ disabled?: boolean;
69
+ /** Whether the button is in a loading state */
70
+ loading?: boolean;
71
+ /** Icon to display in the button (required) */
72
+ icon: React.ReactNode;
73
+ /** Click handler */
74
+ onPress?: () => void;
75
+ /**
76
+ * Accessible label for screen readers (REQUIRED for icon-only buttons)
77
+ * Since icon buttons have no visible text, this label is essential for accessibility.
78
+ * @example aria-label="Close dialog"
79
+ * @example aria-label="Open settings menu"
80
+ */
81
+ "aria-label": string;
82
+ /** ID of element that describes this button */
83
+ "aria-describedby"?: string;
84
+ /** Indicates the button controls an expandable element */
85
+ "aria-expanded"?: boolean;
86
+ /** Indicates the type of popup triggered by the button */
87
+ "aria-haspopup"?: boolean | "menu" | "listbox" | "tree" | "grid" | "dialog";
88
+ /** Indicates the button is pressed (for toggle buttons) */
89
+ "aria-pressed"?: boolean | "mixed";
90
+ /** ID of the element this button controls */
91
+ "aria-controls"?: string;
92
+ /** Test ID for testing frameworks */
93
+ testID?: string;
94
+ /** HTML id attribute */
95
+ id?: string;
96
+ /** HTML type attribute for the button */
97
+ type?: "button" | "submit" | "reset";
98
+ }
99
+ /**
100
+ * IconButton - An accessible icon-only button component
101
+ *
102
+ * Renders as a semantic `<button>` element with full ARIA support.
103
+ * Supports various visual variants, sizes, and states including loading.
104
+ *
105
+ * ## Accessibility Features
106
+ *
107
+ * - **Semantic HTML**: Renders as a native `<button>` element
108
+ * - **Required aria-label**: Ensures screen readers can announce the button's purpose
109
+ * - **Keyboard Navigation**: Focusable via Tab, activated with Enter or Space
110
+ * - **ARIA States**: Properly announces disabled and loading states
111
+ * - **Focus Indicator**: Visible focus ring for keyboard navigation
112
+ * - **Screen Reader Support**: Announces button label, state, and any associated descriptions
113
+ *
114
+ * ## Usage
115
+ *
116
+ * ```tsx
117
+ * // Basic usage - aria-label is required
118
+ * <IconButton icon={<CloseIcon />} aria-label="Close dialog" onPress={handleClose} />
119
+ *
120
+ * // Toggle button
121
+ * <IconButton
122
+ * icon={<MenuIcon />}
123
+ * aria-label="Toggle menu"
124
+ * aria-expanded={isOpen}
125
+ * aria-controls="menu-id"
126
+ * onPress={toggleMenu}
127
+ * />
128
+ *
129
+ * // Loading state
130
+ * <IconButton icon={<SaveIcon />} aria-label="Save changes" loading />
131
+ * ```
132
+ */
133
+ declare const IconButton: React.FC<IconButtonProps>;
134
+
135
+ interface FlexButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "type"> {
136
+ /** Button content */
137
+ children: ReactNode;
138
+ /** Visual variant of the button */
139
+ variant?: "brand" | "primary" | "secondary" | "tertiary" | "brandExtra" | "inverse";
140
+ /** Size of the button */
141
+ size?: "xl" | "l" | "m" | "s" | "xs";
142
+ /** Whether to show background fill */
143
+ background?: boolean;
144
+ /** Whether the button is disabled */
145
+ disabled?: boolean;
146
+ /** Whether the button is in a loading state */
147
+ loading?: boolean;
148
+ /** Icon to display on the left side */
149
+ iconLeft?: ReactNode;
150
+ /** Icon to display on the right side */
151
+ iconRight?: ReactNode;
152
+ /** Click handler */
153
+ onPress?: () => void;
154
+ /** HTML type attribute for the button */
155
+ type?: "button" | "submit" | "reset";
156
+ /** Accessible label for screen readers */
157
+ "aria-label"?: string;
158
+ /** ID of element that describes this button */
159
+ "aria-describedby"?: string;
160
+ /** Indicates the button controls an expandable element */
161
+ "aria-expanded"?: boolean;
162
+ /** Indicates the type of popup triggered by the button */
163
+ "aria-haspopup"?: boolean | "menu" | "listbox" | "tree" | "grid" | "dialog";
164
+ /** Indicates the button is pressed (for toggle buttons) */
165
+ "aria-pressed"?: boolean | "mixed";
166
+ /** ID of the element this button controls */
167
+ "aria-controls"?: string;
168
+ /** Test ID for testing frameworks */
169
+ testID?: string;
170
+ }
171
+ /**
172
+ * FlexButton - A compact button component designed for use in modals and popups.
173
+ *
174
+ * Renders as a semantic `<button>` element with full ARIA support.
175
+ *
176
+ * ## Accessibility Features
177
+ *
178
+ * - **Semantic HTML**: Renders as a native `<button>` element
179
+ * - **Keyboard Navigation**: Focusable via Tab, activated with Enter or Space
180
+ * - **ARIA States**: Properly announces disabled and loading states
181
+ * - **Focus Indicator**: Visible focus ring for keyboard navigation
182
+ * - **Screen Reader Support**: Announces button label, state, and any associated descriptions
183
+ */
184
+ declare const FlexButton: React.FC<FlexButtonProps>;
185
+
186
+ interface ButtonGroupProps {
187
+ /**
188
+ * Layout orientation of the buttons
189
+ * @default 'horizontal'
190
+ */
191
+ orientation?: "horizontal" | "vertical";
192
+ /**
193
+ * Size of the button group, determines default gap between buttons
194
+ * @default 'm'
195
+ */
196
+ size?: "xl" | "l" | "m" | "s" | "xs";
197
+ /**
198
+ * Buttons to be grouped
199
+ */
200
+ children: React.ReactNode;
201
+ /**
202
+ * Optional description text below the buttons
203
+ */
204
+ description?: string;
205
+ /**
206
+ * Optional error message text below the buttons
207
+ */
208
+ error?: string;
209
+ /**
210
+ * Custom gap between buttons (in pixels). If not provided, uses size and orientation based default.
211
+ */
212
+ gap?: number;
213
+ /**
214
+ * Accessible label for the button group
215
+ */
216
+ "aria-label"?: string;
217
+ /**
218
+ * ID of element that labels this button group
219
+ */
220
+ "aria-labelledby"?: string;
221
+ /**
222
+ * ID of element that describes this button group
223
+ */
224
+ "aria-describedby"?: string;
225
+ /**
226
+ * HTML id attribute
227
+ */
228
+ id?: string;
229
+ /**
230
+ * Test ID for testing frameworks
231
+ */
232
+ testID?: string;
233
+ }
234
+ /**
235
+ * ButtonGroup - A container for grouping related buttons
236
+ *
237
+ * Provides semantic grouping for related actions with proper accessibility support.
238
+ *
239
+ * ## Accessibility Features
240
+ *
241
+ * - **Semantic Grouping**: Uses `role="group"` to indicate related buttons
242
+ * - **Accessible Name**: Supports `aria-label` or `aria-labelledby` to describe the group's purpose
243
+ * - **Error Announcements**: Errors are announced to screen readers via `aria-live`
244
+ * - **Description Support**: Optional description text for additional context
245
+ *
246
+ */
247
+ declare const ButtonGroup: React.FC<ButtonGroupProps>;
248
+
249
+ export { Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, FlexButton, type FlexButtonProps, IconButton, type IconButtonProps };
@@ -0,0 +1,249 @@
1
+ import React, { ReactNode } from 'react';
2
+
3
+ interface ButtonProps {
4
+ /** Visual variant of the button */
5
+ variant?: "primary" | "secondary";
6
+ /** Color tone of the button */
7
+ tone?: "brand" | "brandExtra" | "alert" | "mono";
8
+ /** Size of the button */
9
+ size?: "xl" | "l" | "m" | "s" | "xs";
10
+ /** Whether the button is disabled */
11
+ disabled?: boolean;
12
+ /** Whether the button is in a loading state */
13
+ loading?: boolean;
14
+ /** Button content */
15
+ children: React.ReactNode;
16
+ /** Click handler */
17
+ onPress?: () => void;
18
+ /** Icon to display on the left side */
19
+ iconLeft?: React.ReactNode;
20
+ /** Icon to display on the right side */
21
+ iconRight?: React.ReactNode;
22
+ /** Accessible label for screen readers (defaults to children if string) */
23
+ "aria-label"?: string;
24
+ /** ID of element that describes this button */
25
+ "aria-describedby"?: string;
26
+ /** Indicates the button controls an expandable element */
27
+ "aria-expanded"?: boolean;
28
+ /** Indicates the type of popup triggered by the button */
29
+ "aria-haspopup"?: boolean | "menu" | "listbox" | "tree" | "grid" | "dialog";
30
+ /** Indicates the button is pressed (for toggle buttons) */
31
+ "aria-pressed"?: boolean | "mixed";
32
+ /** ID of the element this button controls */
33
+ "aria-controls"?: string;
34
+ /** Test ID for testing frameworks */
35
+ testID?: string;
36
+ /** HTML id attribute */
37
+ id?: string;
38
+ /** HTML type attribute for the button */
39
+ type?: "button" | "submit" | "reset";
40
+ /** Whether the button should take up the full width of its container */
41
+ fullWidth?: boolean;
42
+ }
43
+ /**
44
+ * Button - An accessible button component
45
+ *
46
+ * Renders as a semantic `<button>` element with full ARIA support.
47
+ * Supports various visual variants, sizes, and states including loading.
48
+ *
49
+ * ## Accessibility Features
50
+ *
51
+ * - **Semantic HTML**: Renders as a native `<button>` element
52
+ * - **Keyboard Navigation**: Focusable via Tab, activated with Enter or Space
53
+ * - **ARIA States**: Properly announces disabled and loading states
54
+ * - **Focus Indicator**: Visible focus ring for keyboard navigation
55
+ * - **Screen Reader Support**: Announces button label, state, and any associated descriptions
56
+ *
57
+ */
58
+ declare const Button: React.FC<ButtonProps>;
59
+
60
+ interface IconButtonProps {
61
+ /** Visual variant of the button */
62
+ variant?: "primary" | "secondary";
63
+ /** Color tone of the button */
64
+ tone?: "brand" | "brandExtra" | "alert" | "mono";
65
+ /** Size of the button */
66
+ size?: "xl" | "l" | "m" | "s" | "xs";
67
+ /** Whether the button is disabled */
68
+ disabled?: boolean;
69
+ /** Whether the button is in a loading state */
70
+ loading?: boolean;
71
+ /** Icon to display in the button (required) */
72
+ icon: React.ReactNode;
73
+ /** Click handler */
74
+ onPress?: () => void;
75
+ /**
76
+ * Accessible label for screen readers (REQUIRED for icon-only buttons)
77
+ * Since icon buttons have no visible text, this label is essential for accessibility.
78
+ * @example aria-label="Close dialog"
79
+ * @example aria-label="Open settings menu"
80
+ */
81
+ "aria-label": string;
82
+ /** ID of element that describes this button */
83
+ "aria-describedby"?: string;
84
+ /** Indicates the button controls an expandable element */
85
+ "aria-expanded"?: boolean;
86
+ /** Indicates the type of popup triggered by the button */
87
+ "aria-haspopup"?: boolean | "menu" | "listbox" | "tree" | "grid" | "dialog";
88
+ /** Indicates the button is pressed (for toggle buttons) */
89
+ "aria-pressed"?: boolean | "mixed";
90
+ /** ID of the element this button controls */
91
+ "aria-controls"?: string;
92
+ /** Test ID for testing frameworks */
93
+ testID?: string;
94
+ /** HTML id attribute */
95
+ id?: string;
96
+ /** HTML type attribute for the button */
97
+ type?: "button" | "submit" | "reset";
98
+ }
99
+ /**
100
+ * IconButton - An accessible icon-only button component
101
+ *
102
+ * Renders as a semantic `<button>` element with full ARIA support.
103
+ * Supports various visual variants, sizes, and states including loading.
104
+ *
105
+ * ## Accessibility Features
106
+ *
107
+ * - **Semantic HTML**: Renders as a native `<button>` element
108
+ * - **Required aria-label**: Ensures screen readers can announce the button's purpose
109
+ * - **Keyboard Navigation**: Focusable via Tab, activated with Enter or Space
110
+ * - **ARIA States**: Properly announces disabled and loading states
111
+ * - **Focus Indicator**: Visible focus ring for keyboard navigation
112
+ * - **Screen Reader Support**: Announces button label, state, and any associated descriptions
113
+ *
114
+ * ## Usage
115
+ *
116
+ * ```tsx
117
+ * // Basic usage - aria-label is required
118
+ * <IconButton icon={<CloseIcon />} aria-label="Close dialog" onPress={handleClose} />
119
+ *
120
+ * // Toggle button
121
+ * <IconButton
122
+ * icon={<MenuIcon />}
123
+ * aria-label="Toggle menu"
124
+ * aria-expanded={isOpen}
125
+ * aria-controls="menu-id"
126
+ * onPress={toggleMenu}
127
+ * />
128
+ *
129
+ * // Loading state
130
+ * <IconButton icon={<SaveIcon />} aria-label="Save changes" loading />
131
+ * ```
132
+ */
133
+ declare const IconButton: React.FC<IconButtonProps>;
134
+
135
+ interface FlexButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "type"> {
136
+ /** Button content */
137
+ children: ReactNode;
138
+ /** Visual variant of the button */
139
+ variant?: "brand" | "primary" | "secondary" | "tertiary" | "brandExtra" | "inverse";
140
+ /** Size of the button */
141
+ size?: "xl" | "l" | "m" | "s" | "xs";
142
+ /** Whether to show background fill */
143
+ background?: boolean;
144
+ /** Whether the button is disabled */
145
+ disabled?: boolean;
146
+ /** Whether the button is in a loading state */
147
+ loading?: boolean;
148
+ /** Icon to display on the left side */
149
+ iconLeft?: ReactNode;
150
+ /** Icon to display on the right side */
151
+ iconRight?: ReactNode;
152
+ /** Click handler */
153
+ onPress?: () => void;
154
+ /** HTML type attribute for the button */
155
+ type?: "button" | "submit" | "reset";
156
+ /** Accessible label for screen readers */
157
+ "aria-label"?: string;
158
+ /** ID of element that describes this button */
159
+ "aria-describedby"?: string;
160
+ /** Indicates the button controls an expandable element */
161
+ "aria-expanded"?: boolean;
162
+ /** Indicates the type of popup triggered by the button */
163
+ "aria-haspopup"?: boolean | "menu" | "listbox" | "tree" | "grid" | "dialog";
164
+ /** Indicates the button is pressed (for toggle buttons) */
165
+ "aria-pressed"?: boolean | "mixed";
166
+ /** ID of the element this button controls */
167
+ "aria-controls"?: string;
168
+ /** Test ID for testing frameworks */
169
+ testID?: string;
170
+ }
171
+ /**
172
+ * FlexButton - A compact button component designed for use in modals and popups.
173
+ *
174
+ * Renders as a semantic `<button>` element with full ARIA support.
175
+ *
176
+ * ## Accessibility Features
177
+ *
178
+ * - **Semantic HTML**: Renders as a native `<button>` element
179
+ * - **Keyboard Navigation**: Focusable via Tab, activated with Enter or Space
180
+ * - **ARIA States**: Properly announces disabled and loading states
181
+ * - **Focus Indicator**: Visible focus ring for keyboard navigation
182
+ * - **Screen Reader Support**: Announces button label, state, and any associated descriptions
183
+ */
184
+ declare const FlexButton: React.FC<FlexButtonProps>;
185
+
186
+ interface ButtonGroupProps {
187
+ /**
188
+ * Layout orientation of the buttons
189
+ * @default 'horizontal'
190
+ */
191
+ orientation?: "horizontal" | "vertical";
192
+ /**
193
+ * Size of the button group, determines default gap between buttons
194
+ * @default 'm'
195
+ */
196
+ size?: "xl" | "l" | "m" | "s" | "xs";
197
+ /**
198
+ * Buttons to be grouped
199
+ */
200
+ children: React.ReactNode;
201
+ /**
202
+ * Optional description text below the buttons
203
+ */
204
+ description?: string;
205
+ /**
206
+ * Optional error message text below the buttons
207
+ */
208
+ error?: string;
209
+ /**
210
+ * Custom gap between buttons (in pixels). If not provided, uses size and orientation based default.
211
+ */
212
+ gap?: number;
213
+ /**
214
+ * Accessible label for the button group
215
+ */
216
+ "aria-label"?: string;
217
+ /**
218
+ * ID of element that labels this button group
219
+ */
220
+ "aria-labelledby"?: string;
221
+ /**
222
+ * ID of element that describes this button group
223
+ */
224
+ "aria-describedby"?: string;
225
+ /**
226
+ * HTML id attribute
227
+ */
228
+ id?: string;
229
+ /**
230
+ * Test ID for testing frameworks
231
+ */
232
+ testID?: string;
233
+ }
234
+ /**
235
+ * ButtonGroup - A container for grouping related buttons
236
+ *
237
+ * Provides semantic grouping for related actions with proper accessibility support.
238
+ *
239
+ * ## Accessibility Features
240
+ *
241
+ * - **Semantic Grouping**: Uses `role="group"` to indicate related buttons
242
+ * - **Accessible Name**: Supports `aria-label` or `aria-labelledby` to describe the group's purpose
243
+ * - **Error Announcements**: Errors are announced to screen readers via `aria-live`
244
+ * - **Description Support**: Optional description text for additional context
245
+ *
246
+ */
247
+ declare const ButtonGroup: React.FC<ButtonGroupProps>;
248
+
249
+ export { Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, FlexButton, type FlexButtonProps, IconButton, type IconButtonProps };