@xsolla/xui-button 0.206.2 → 0.207.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 +46 -0
- package/native/index.d.mts +17 -0
- package/native/index.d.ts +17 -0
- package/native/index.js +3 -2
- package/native/index.js.map +1 -1
- package/native/index.mjs +3 -2
- package/native/index.mjs.map +1 -1
- package/package.json +4 -4
- package/web/index.d.mts +17 -0
- package/web/index.d.ts +17 -0
- package/web/index.js +3 -2
- package/web/index.js.map +1 -1
- package/web/index.mjs +3 -2
- package/web/index.mjs.map +1 -1
package/README.md
CHANGED
|
@@ -255,6 +255,45 @@ export default function ButtonGroupExample() {
|
|
|
255
255
|
}
|
|
256
256
|
```
|
|
257
257
|
|
|
258
|
+
### Split Button Group
|
|
259
|
+
|
|
260
|
+
A horizontal group picks its layout from the child count: 3 or more buttons use
|
|
261
|
+
the split (`space-between`) layout — first button pinned to the left edge, the
|
|
262
|
+
rest grouped on the right — while 1–2 buttons stretch to fill the row.
|
|
263
|
+
|
|
264
|
+
Pass `split` to override that heuristic in either direction. It is the usual
|
|
265
|
+
choice for a wizard footer, where Back belongs on the left and Next on the
|
|
266
|
+
right. `split` has no effect on vertical groups or on a single button.
|
|
267
|
+
|
|
268
|
+
```tsx
|
|
269
|
+
import * as React from "react";
|
|
270
|
+
import { Button, ButtonGroup } from "@xsolla/xui-button";
|
|
271
|
+
import { ArrowRight } from "@xsolla/xui-icons-base";
|
|
272
|
+
|
|
273
|
+
export default function SplitButtonGroup() {
|
|
274
|
+
return (
|
|
275
|
+
<>
|
|
276
|
+
{/* Two buttons, split apart instead of stretched */}
|
|
277
|
+
<ButtonGroup split aria-label="Wizard navigation">
|
|
278
|
+
<Button variant="secondary" tone="mono">
|
|
279
|
+
Back
|
|
280
|
+
</Button>
|
|
281
|
+
<Button iconRight={<ArrowRight />}>Next</Button>
|
|
282
|
+
</ButtonGroup>
|
|
283
|
+
|
|
284
|
+
{/* Three buttons kept together instead of split */}
|
|
285
|
+
<ButtonGroup split={false} aria-label="Grouped actions">
|
|
286
|
+
<Button variant="secondary" tone="mono">
|
|
287
|
+
Cancel
|
|
288
|
+
</Button>
|
|
289
|
+
<Button variant="secondary">Save Draft</Button>
|
|
290
|
+
<Button>Submit</Button>
|
|
291
|
+
</ButtonGroup>
|
|
292
|
+
</>
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
258
297
|
### Vertical Button Group
|
|
259
298
|
|
|
260
299
|
```tsx
|
|
@@ -516,6 +555,7 @@ A container for grouping related buttons together.
|
|
|
516
555
|
| :--------------- | :------------------------------------- | :------------- | :--------------------------------------------------- |
|
|
517
556
|
| children | `ReactNode` | - | **Required.** Button children to group. |
|
|
518
557
|
| orientation | `"horizontal" \| "vertical"` | `"horizontal"` | Layout direction of the buttons. |
|
|
558
|
+
| split | `boolean` | - | Force or suppress the split space-between layout. |
|
|
519
559
|
| size | `"xl" \| "lg" \| "md" \| "sm" \| "xs"` | `"md"` | Size applied to the group spacing. |
|
|
520
560
|
| gap | `number` | - | Custom gap between buttons (overrides size default). |
|
|
521
561
|
| description | `string` | - | Description text shown below the group. |
|
|
@@ -526,6 +566,12 @@ A container for grouping related buttons together.
|
|
|
526
566
|
| id | `string` | - | HTML id attribute. |
|
|
527
567
|
| testID | `string` | - | Test identifier for testing frameworks. |
|
|
528
568
|
|
|
569
|
+
`split` overrides the child-count heuristic that otherwise decides the
|
|
570
|
+
horizontal layout. Pass `split` to give a 2-button group the space-between
|
|
571
|
+
layout (the buttons keep their natural width rather than stretching to fill the
|
|
572
|
+
row), or `split={false}` to keep a 3+ button group together. It is ignored when
|
|
573
|
+
`orientation="vertical"` or when the group has fewer than 2 children.
|
|
574
|
+
|
|
529
575
|
**ButtonGroup Gap Defaults:**
|
|
530
576
|
|
|
531
577
|
| Size | Vertical Gap | Horizontal Gap |
|
package/native/index.d.mts
CHANGED
|
@@ -318,6 +318,23 @@ interface ButtonGroupProps extends ThemeOverrideProps {
|
|
|
318
318
|
* @default 'horizontal'
|
|
319
319
|
*/
|
|
320
320
|
orientation?: "horizontal" | "vertical";
|
|
321
|
+
/**
|
|
322
|
+
* Force or suppress the split ("space-between") layout, in which the first
|
|
323
|
+
* button is pinned to the left edge and the remaining buttons are grouped
|
|
324
|
+
* on the right.
|
|
325
|
+
*
|
|
326
|
+
* When omitted, the layout is chosen by child count: horizontal groups with
|
|
327
|
+
* 3 or more buttons split, smaller groups do not. Set `split` to override
|
|
328
|
+
* that heuristic in either direction:
|
|
329
|
+
*
|
|
330
|
+
* - `split` — split a 2-button group (buttons keep their natural width
|
|
331
|
+
* instead of stretching to fill the row)
|
|
332
|
+
* - `split={false}` — opt a 3+ button group out of the split layout
|
|
333
|
+
*
|
|
334
|
+
* Has no effect when `orientation="vertical"` or when the group has fewer
|
|
335
|
+
* than 2 children.
|
|
336
|
+
*/
|
|
337
|
+
split?: boolean;
|
|
321
338
|
/**
|
|
322
339
|
* Size of the button group, determines default gap between buttons
|
|
323
340
|
* @default 'md'
|
package/native/index.d.ts
CHANGED
|
@@ -318,6 +318,23 @@ interface ButtonGroupProps extends ThemeOverrideProps {
|
|
|
318
318
|
* @default 'horizontal'
|
|
319
319
|
*/
|
|
320
320
|
orientation?: "horizontal" | "vertical";
|
|
321
|
+
/**
|
|
322
|
+
* Force or suppress the split ("space-between") layout, in which the first
|
|
323
|
+
* button is pinned to the left edge and the remaining buttons are grouped
|
|
324
|
+
* on the right.
|
|
325
|
+
*
|
|
326
|
+
* When omitted, the layout is chosen by child count: horizontal groups with
|
|
327
|
+
* 3 or more buttons split, smaller groups do not. Set `split` to override
|
|
328
|
+
* that heuristic in either direction:
|
|
329
|
+
*
|
|
330
|
+
* - `split` — split a 2-button group (buttons keep their natural width
|
|
331
|
+
* instead of stretching to fill the row)
|
|
332
|
+
* - `split={false}` — opt a 3+ button group out of the split layout
|
|
333
|
+
*
|
|
334
|
+
* Has no effect when `orientation="vertical"` or when the group has fewer
|
|
335
|
+
* than 2 children.
|
|
336
|
+
*/
|
|
337
|
+
split?: boolean;
|
|
321
338
|
/**
|
|
322
339
|
* Size of the button group, determines default gap between buttons
|
|
323
340
|
* @default 'md'
|
package/native/index.js
CHANGED
|
@@ -1485,6 +1485,7 @@ var import_xui_core5 = require("@xsolla/xui-core");
|
|
|
1485
1485
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1486
1486
|
var ButtonGroup = ({
|
|
1487
1487
|
orientation = "horizontal",
|
|
1488
|
+
split,
|
|
1488
1489
|
size = "md",
|
|
1489
1490
|
children,
|
|
1490
1491
|
description,
|
|
@@ -1512,7 +1513,7 @@ var ButtonGroup = ({
|
|
|
1512
1513
|
};
|
|
1513
1514
|
const flatChildren = flattenChildren(children);
|
|
1514
1515
|
const childCount = flatChildren.length;
|
|
1515
|
-
const useSpaceBetween = orientation === "horizontal" && childCount > 2;
|
|
1516
|
+
const useSpaceBetween = orientation === "horizontal" && childCount > 1 && (split ?? childCount > 2);
|
|
1516
1517
|
const verticalGapMap = {
|
|
1517
1518
|
xl: 16,
|
|
1518
1519
|
lg: 16,
|
|
@@ -1535,7 +1536,7 @@ var ButtonGroup = ({
|
|
|
1535
1536
|
error && errorId ? errorId : void 0,
|
|
1536
1537
|
description && descriptionId ? descriptionId : void 0
|
|
1537
1538
|
].filter(Boolean).join(" ") || void 0;
|
|
1538
|
-
const stretchChildren = orientation === "vertical" || orientation === "horizontal" && childCount <= 2;
|
|
1539
|
+
const stretchChildren = orientation === "vertical" || orientation === "horizontal" && childCount <= 2 && !useSpaceBetween;
|
|
1539
1540
|
const processChildren = (childrenToProcess) => {
|
|
1540
1541
|
if (stretchChildren) {
|
|
1541
1542
|
return childrenToProcess.map((child, index) => {
|