@xsolla/xui-button 0.192.0 → 0.193.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/README.md CHANGED
@@ -476,11 +476,13 @@ A button variant that displays only an icon. Requires `aria-label` for accessibi
476
476
 
477
477
  A flexible button with more granular control over background, hover fills, and styling.
478
478
 
479
+ Forwards a `ref` to the underlying `<button>` element, and inherits `ThemeOverrideProps` (`themeMode`, `themeProductContext`).
480
+
479
481
  **FlexButton Props:**
480
482
 
481
483
  | Prop | Type | Default | Description |
482
484
  | :-------------- | :------------------------------------------------------------------------------- | :--------- | :------------------------------------------------------------- |
483
- | children | `ReactNode` | - | The button label content. |
485
+ | children | `ReactNode` | - | The button label content. Optional — omit for an icon-only button, which renders no text slot so the icon stays centred in the hit area. |
484
486
  | variant | `"brand" \| "primary" \| "secondary" \| "tertiary" \| "brandExtra" \| "inverse"` | `"brand"` | The visual style variant. |
485
487
  | size | `"xl" \| "lg" \| "md" \| "sm" \| "xs"` | `"md"` | The size of the button. |
486
488
  | background | `boolean` | `false` | Whether to show background fill. |
@@ -492,6 +494,16 @@ A flexible button with more granular control over background, hover fills, and s
492
494
  | onPress | `() => void` | - | Callback fired when button is pressed. |
493
495
  | type | `"button" \| "submit" \| "reset"` | `"button"` | The HTML button type attribute. |
494
496
 
497
+ **`getFlexButtonBoxSize(size?)`**
498
+
499
+ Returns the square side, in px, of an icon-only `FlexButton` — `20 | 22 | 28 | 32 | 36` for `xs`–`xl`, defaulting to `md`. Use it when a layout has to reserve a matching column for a button it does not render itself (as `Modal`'s header does), instead of hardcoding the number. `noPadding` does not change it; only the inner padding is removed.
500
+
501
+ ```tsx
502
+ import { getFlexButtonBoxSize } from "@xsolla/xui-button";
503
+
504
+ <Box style={{ minWidth: getFlexButtonBoxSize("xl") }} />; // 36
505
+ ```
506
+
495
507
  ---
496
508
 
497
509
  ### ButtonGroup
@@ -169,7 +169,7 @@ interface IconButtonProps extends ThemeOverrideProps {
169
169
  */
170
170
  declare const IconButton: React.FC<IconButtonProps>;
171
171
 
172
- interface FlexButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "type"> {
172
+ interface FlexButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "type">, ThemeOverrideProps {
173
173
  /**
174
174
  * Button label. Omit for icon-only buttons (provide `aria-label`).
175
175
  *
@@ -229,6 +229,11 @@ interface FlexButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElem
229
229
  "aria-controls"?: string;
230
230
  testID?: string;
231
231
  }
232
+ /**
233
+ * Total hit-area size of an icon-only `FlexButton`, in px. `noPadding` does not
234
+ * change it — only the inner padding is removed.
235
+ */
236
+ declare const getFlexButtonBoxSize: (size?: NonNullable<FlexButtonProps["size"]>) => number;
232
237
  /**
233
238
  * FlexButton - A compact button component designed for use in modals and popups.
234
239
  *
@@ -255,7 +260,7 @@ interface FlexButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElem
255
260
  * - **Focus Indicator**: Visible focus ring for keyboard navigation
256
261
  * - **Screen Reader Support**: Announces button label, state, and any associated descriptions
257
262
  */
258
- declare const FlexButton: React.FC<FlexButtonProps>;
263
+ declare const FlexButton: React.ForwardRefExoticComponent<FlexButtonProps & React.RefAttributes<HTMLButtonElement>>;
259
264
 
260
265
  interface AppButtonProps extends ThemeOverrideProps {
261
266
  /** Size of the button */
@@ -364,4 +369,4 @@ interface ButtonGroupProps extends ThemeOverrideProps {
364
369
  */
365
370
  declare const ButtonGroup: React.FC<ButtonGroupProps>;
366
371
 
367
- export { AppButton, type AppButtonProps, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, FlexButton, type FlexButtonProps, IconButton, type IconButtonProps };
372
+ export { AppButton, type AppButtonProps, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, FlexButton, type FlexButtonProps, IconButton, type IconButtonProps, getFlexButtonBoxSize };
package/native/index.d.ts CHANGED
@@ -169,7 +169,7 @@ interface IconButtonProps extends ThemeOverrideProps {
169
169
  */
170
170
  declare const IconButton: React.FC<IconButtonProps>;
171
171
 
172
- interface FlexButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "type"> {
172
+ interface FlexButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "type">, ThemeOverrideProps {
173
173
  /**
174
174
  * Button label. Omit for icon-only buttons (provide `aria-label`).
175
175
  *
@@ -229,6 +229,11 @@ interface FlexButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElem
229
229
  "aria-controls"?: string;
230
230
  testID?: string;
231
231
  }
232
+ /**
233
+ * Total hit-area size of an icon-only `FlexButton`, in px. `noPadding` does not
234
+ * change it — only the inner padding is removed.
235
+ */
236
+ declare const getFlexButtonBoxSize: (size?: NonNullable<FlexButtonProps["size"]>) => number;
232
237
  /**
233
238
  * FlexButton - A compact button component designed for use in modals and popups.
234
239
  *
@@ -255,7 +260,7 @@ interface FlexButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElem
255
260
  * - **Focus Indicator**: Visible focus ring for keyboard navigation
256
261
  * - **Screen Reader Support**: Announces button label, state, and any associated descriptions
257
262
  */
258
- declare const FlexButton: React.FC<FlexButtonProps>;
263
+ declare const FlexButton: React.ForwardRefExoticComponent<FlexButtonProps & React.RefAttributes<HTMLButtonElement>>;
259
264
 
260
265
  interface AppButtonProps extends ThemeOverrideProps {
261
266
  /** Size of the button */
@@ -364,4 +369,4 @@ interface ButtonGroupProps extends ThemeOverrideProps {
364
369
  */
365
370
  declare const ButtonGroup: React.FC<ButtonGroupProps>;
366
371
 
367
- export { AppButton, type AppButtonProps, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, FlexButton, type FlexButtonProps, IconButton, type IconButtonProps };
372
+ export { AppButton, type AppButtonProps, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, FlexButton, type FlexButtonProps, IconButton, type IconButtonProps, getFlexButtonBoxSize };