@xsolla/xui-toggle-button-group 0.101.0-pr166.1772004027

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 ADDED
@@ -0,0 +1,78 @@
1
+ # @xsolla/xui-toggle-button-group
2
+
3
+ A control for picking one or several options from a linear set of closely related options. Can be used to filter or to sort elements.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @xsolla/xui-toggle-button-group
9
+ # or
10
+ yarn add @xsolla/xui-toggle-button-group
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```tsx
16
+ import { ToggleButtonGroup } from '@xsolla/xui-toggle-button-group';
17
+
18
+ // Single selection (default)
19
+ const [value, setValue] = useState('item1');
20
+
21
+ <ToggleButtonGroup
22
+ items={[
23
+ { id: 'item1', label: 'Option 1' },
24
+ { id: 'item2', label: 'Option 2' },
25
+ { id: 'item3', label: 'Option 3' },
26
+ ]}
27
+ value={value}
28
+ onChange={(v) => setValue(v as string)}
29
+ />
30
+
31
+ // Multiple selection
32
+ const [values, setValues] = useState(['item1', 'item3']);
33
+
34
+ <ToggleButtonGroup
35
+ items={[
36
+ { id: 'item1', label: 'Option 1' },
37
+ { id: 'item2', label: 'Option 2' },
38
+ { id: 'item3', label: 'Option 3' },
39
+ ]}
40
+ value={values}
41
+ onChange={(v) => setValues(v as string[])}
42
+ multiple
43
+ />
44
+ ```
45
+
46
+ ## Props
47
+
48
+ | Prop | Type | Default | Description |
49
+ |------|------|---------|-------------|
50
+ | `items` | `ToggleButtonGroupItem[]` | required | Array of items to display |
51
+ | `value` | `string \| string[]` | - | Controlled value(s) |
52
+ | `defaultValue` | `string \| string[]` | - | Default value(s) for uncontrolled mode |
53
+ | `onChange` | `(value: string \| string[]) => void` | - | Callback when selection changes |
54
+ | `size` | `'xl' \| 'lg' \| 'md' \| 'sm'` | `'md'` | Size variant |
55
+ | `appearance` | `'separated' \| 'united'` | `'separated'` | Visual style |
56
+ | `multiple` | `boolean` | `false` | Allow multiple selections |
57
+ | `id` | `string` | - | HTML id attribute |
58
+ | `testID` | `string` | - | Test ID for testing frameworks |
59
+ | `aria-label` | `string` | - | Accessible label for the group |
60
+ | `aria-labelledby` | `string` | - | ID of element that labels this group |
61
+
62
+ ### ToggleButtonGroupItem
63
+
64
+ | Prop | Type | Description |
65
+ |------|------|-------------|
66
+ | `id` | `string` | Unique identifier |
67
+ | `label` | `string` | Display text |
68
+ | `iconLeft` | `ReactNode` | Optional icon on the left |
69
+ | `iconRight` | `ReactNode` | Optional icon on the right |
70
+ | `disabled` | `boolean` | Whether the item is disabled |
71
+ | `aria-label` | `string` | Accessible label for screen readers |
72
+
73
+ ## Accessibility
74
+
75
+ - Uses `role="radiogroup"` for single selection, `role="group"` for multiple
76
+ - Arrow keys navigate between items
77
+ - Enter/Space selects/toggles items
78
+ - Proper `aria-checked` and `aria-disabled` states
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+
3
+ type ToggleButtonGroupSize = "xl" | "lg" | "md" | "sm";
4
+ type ToggleButtonGroupAppearance = "separated" | "united";
5
+ interface ToggleButtonGroupItem {
6
+ /** Unique identifier for the item */
7
+ id: string;
8
+ /** Display label for the item */
9
+ label: string;
10
+ /** Optional icon to display on the left */
11
+ iconLeft?: React.ReactNode;
12
+ /** Optional icon to display on the right */
13
+ iconRight?: React.ReactNode;
14
+ /** Whether the item is disabled */
15
+ disabled?: boolean;
16
+ /** Accessible label for screen readers */
17
+ "aria-label"?: string;
18
+ }
19
+ interface ToggleButtonGroupProps {
20
+ /** Array of items */
21
+ items: ToggleButtonGroupItem[];
22
+ /** ID(s) of the currently active item(s). For single selection, pass a string. For multiple selection, pass an array. */
23
+ value?: string | string[];
24
+ /** Default value(s) for uncontrolled mode */
25
+ defaultValue?: string | string[];
26
+ /** Callback when selection changes. Returns string for single selection, string[] for multiple. */
27
+ onChange?: (value: string | string[]) => void;
28
+ /** Size variant */
29
+ size?: ToggleButtonGroupSize;
30
+ /** Visual appearance - separated has gaps, united has connected items */
31
+ appearance?: ToggleButtonGroupAppearance;
32
+ /** Whether multiple items can be selected */
33
+ multiple?: boolean;
34
+ /** HTML id attribute */
35
+ id?: string;
36
+ /** Test ID for testing frameworks */
37
+ testID?: string;
38
+ /** Accessible label for the group */
39
+ "aria-label"?: string;
40
+ /** ID of element that labels this group */
41
+ "aria-labelledby"?: string;
42
+ }
43
+
44
+ /**
45
+ * ToggleButtonGroup - A control for picking one or several options from a set
46
+ *
47
+ * Used to pick one or several options from a linear set of closely related options.
48
+ * Can be used to filter or to sort elements.
49
+ *
50
+ * ## Accessibility Features
51
+ *
52
+ * - **Role**: Uses `role="radiogroup"` for single selection, `role="group"` for multiple
53
+ * - **Keyboard Navigation**: Arrow keys to navigate, Enter/Space to select
54
+ * - **ARIA**: Proper aria-checked and aria-disabled states
55
+ */
56
+ declare const ToggleButtonGroup: React.FC<ToggleButtonGroupProps>;
57
+
58
+ export { ToggleButtonGroup, type ToggleButtonGroupAppearance, type ToggleButtonGroupItem, type ToggleButtonGroupProps, type ToggleButtonGroupSize };
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+
3
+ type ToggleButtonGroupSize = "xl" | "lg" | "md" | "sm";
4
+ type ToggleButtonGroupAppearance = "separated" | "united";
5
+ interface ToggleButtonGroupItem {
6
+ /** Unique identifier for the item */
7
+ id: string;
8
+ /** Display label for the item */
9
+ label: string;
10
+ /** Optional icon to display on the left */
11
+ iconLeft?: React.ReactNode;
12
+ /** Optional icon to display on the right */
13
+ iconRight?: React.ReactNode;
14
+ /** Whether the item is disabled */
15
+ disabled?: boolean;
16
+ /** Accessible label for screen readers */
17
+ "aria-label"?: string;
18
+ }
19
+ interface ToggleButtonGroupProps {
20
+ /** Array of items */
21
+ items: ToggleButtonGroupItem[];
22
+ /** ID(s) of the currently active item(s). For single selection, pass a string. For multiple selection, pass an array. */
23
+ value?: string | string[];
24
+ /** Default value(s) for uncontrolled mode */
25
+ defaultValue?: string | string[];
26
+ /** Callback when selection changes. Returns string for single selection, string[] for multiple. */
27
+ onChange?: (value: string | string[]) => void;
28
+ /** Size variant */
29
+ size?: ToggleButtonGroupSize;
30
+ /** Visual appearance - separated has gaps, united has connected items */
31
+ appearance?: ToggleButtonGroupAppearance;
32
+ /** Whether multiple items can be selected */
33
+ multiple?: boolean;
34
+ /** HTML id attribute */
35
+ id?: string;
36
+ /** Test ID for testing frameworks */
37
+ testID?: string;
38
+ /** Accessible label for the group */
39
+ "aria-label"?: string;
40
+ /** ID of element that labels this group */
41
+ "aria-labelledby"?: string;
42
+ }
43
+
44
+ /**
45
+ * ToggleButtonGroup - A control for picking one or several options from a set
46
+ *
47
+ * Used to pick one or several options from a linear set of closely related options.
48
+ * Can be used to filter or to sort elements.
49
+ *
50
+ * ## Accessibility Features
51
+ *
52
+ * - **Role**: Uses `role="radiogroup"` for single selection, `role="group"` for multiple
53
+ * - **Keyboard Navigation**: Arrow keys to navigate, Enter/Space to select
54
+ * - **ARIA**: Proper aria-checked and aria-disabled states
55
+ */
56
+ declare const ToggleButtonGroup: React.FC<ToggleButtonGroupProps>;
57
+
58
+ export { ToggleButtonGroup, type ToggleButtonGroupAppearance, type ToggleButtonGroupItem, type ToggleButtonGroupProps, type ToggleButtonGroupSize };
@@ -0,0 +1,482 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.tsx
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ ToggleButtonGroup: () => ToggleButtonGroup
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/ToggleButtonGroup.tsx
38
+ var import_react2 = require("react");
39
+
40
+ // ../primitives-native/src/Box.tsx
41
+ var import_react_native = require("react-native");
42
+ var import_jsx_runtime = require("react/jsx-runtime");
43
+ var Box = ({
44
+ children,
45
+ onPress,
46
+ onLayout,
47
+ onMoveShouldSetResponder,
48
+ onResponderGrant,
49
+ onResponderMove,
50
+ onResponderRelease,
51
+ onResponderTerminate,
52
+ backgroundColor,
53
+ borderColor,
54
+ borderWidth,
55
+ borderBottomWidth,
56
+ borderBottomColor,
57
+ borderTopWidth,
58
+ borderTopColor,
59
+ borderLeftWidth,
60
+ borderLeftColor,
61
+ borderRightWidth,
62
+ borderRightColor,
63
+ borderRadius,
64
+ borderStyle,
65
+ height,
66
+ padding,
67
+ paddingHorizontal,
68
+ paddingVertical,
69
+ margin,
70
+ marginTop,
71
+ marginBottom,
72
+ marginLeft,
73
+ marginRight,
74
+ flexDirection,
75
+ alignItems,
76
+ justifyContent,
77
+ position,
78
+ top,
79
+ bottom,
80
+ left,
81
+ right,
82
+ width,
83
+ flex,
84
+ overflow,
85
+ zIndex,
86
+ hoverStyle,
87
+ pressStyle,
88
+ style,
89
+ "data-testid": dataTestId,
90
+ testID,
91
+ as,
92
+ src,
93
+ alt,
94
+ ...rest
95
+ }) => {
96
+ const getContainerStyle = (pressed) => ({
97
+ backgroundColor: pressed && pressStyle?.backgroundColor ? pressStyle.backgroundColor : backgroundColor,
98
+ borderColor,
99
+ borderWidth,
100
+ borderBottomWidth,
101
+ borderBottomColor,
102
+ borderTopWidth,
103
+ borderTopColor,
104
+ borderLeftWidth,
105
+ borderLeftColor,
106
+ borderRightWidth,
107
+ borderRightColor,
108
+ borderRadius,
109
+ borderStyle,
110
+ overflow,
111
+ zIndex,
112
+ height,
113
+ width,
114
+ padding,
115
+ paddingHorizontal,
116
+ paddingVertical,
117
+ margin,
118
+ marginTop,
119
+ marginBottom,
120
+ marginLeft,
121
+ marginRight,
122
+ flexDirection,
123
+ alignItems,
124
+ justifyContent,
125
+ position,
126
+ top,
127
+ bottom,
128
+ left,
129
+ right,
130
+ flex,
131
+ ...style
132
+ });
133
+ const finalTestID = dataTestId || testID;
134
+ const {
135
+ role,
136
+ tabIndex,
137
+ onKeyDown,
138
+ onKeyUp,
139
+ "aria-label": _ariaLabel,
140
+ "aria-labelledby": _ariaLabelledBy,
141
+ "aria-current": _ariaCurrent,
142
+ "aria-disabled": _ariaDisabled,
143
+ "aria-live": _ariaLive,
144
+ className,
145
+ "data-testid": _dataTestId,
146
+ ...nativeRest
147
+ } = rest;
148
+ if (as === "img" && src) {
149
+ const imageStyle = {
150
+ width,
151
+ height,
152
+ borderRadius,
153
+ position,
154
+ top,
155
+ bottom,
156
+ left,
157
+ right,
158
+ ...style
159
+ };
160
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
161
+ import_react_native.Image,
162
+ {
163
+ source: { uri: src },
164
+ style: imageStyle,
165
+ testID: finalTestID,
166
+ resizeMode: "cover",
167
+ ...nativeRest
168
+ }
169
+ );
170
+ }
171
+ if (onPress) {
172
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
173
+ import_react_native.Pressable,
174
+ {
175
+ onPress,
176
+ onLayout,
177
+ onMoveShouldSetResponder,
178
+ onResponderGrant,
179
+ onResponderMove,
180
+ onResponderRelease,
181
+ onResponderTerminate,
182
+ style: ({ pressed }) => getContainerStyle(pressed),
183
+ testID: finalTestID,
184
+ ...nativeRest,
185
+ children
186
+ }
187
+ );
188
+ }
189
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
190
+ import_react_native.View,
191
+ {
192
+ style: getContainerStyle(),
193
+ testID: finalTestID,
194
+ onLayout,
195
+ onMoveShouldSetResponder,
196
+ onResponderGrant,
197
+ onResponderMove,
198
+ onResponderRelease,
199
+ onResponderTerminate,
200
+ ...nativeRest,
201
+ children
202
+ }
203
+ );
204
+ };
205
+
206
+ // ../primitives-native/src/Text.tsx
207
+ var import_react_native2 = require("react-native");
208
+ var import_jsx_runtime2 = require("react/jsx-runtime");
209
+ var roleMap = {
210
+ alert: "alert",
211
+ heading: "header",
212
+ button: "button",
213
+ link: "link",
214
+ text: "text"
215
+ };
216
+ var Text = ({
217
+ children,
218
+ color,
219
+ fontSize,
220
+ fontWeight,
221
+ fontFamily,
222
+ id,
223
+ role,
224
+ ...props
225
+ }) => {
226
+ let resolvedFontFamily = fontFamily ? fontFamily.split(",")[0].replace(/['"]/g, "").trim() : void 0;
227
+ if (resolvedFontFamily === "Pilat Wide Bold") {
228
+ resolvedFontFamily = void 0;
229
+ }
230
+ const style = {
231
+ color,
232
+ fontSize: typeof fontSize === "number" ? fontSize : void 0,
233
+ fontWeight,
234
+ fontFamily: resolvedFontFamily,
235
+ textDecorationLine: props.textDecoration
236
+ };
237
+ const accessibilityRole = role ? roleMap[role] : void 0;
238
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { style, testID: id, accessibilityRole, children });
239
+ };
240
+
241
+ // ../primitives-native/src/Icon.tsx
242
+ var import_react = __toESM(require("react"));
243
+ var import_react_native3 = require("react-native");
244
+ var import_jsx_runtime3 = require("react/jsx-runtime");
245
+ var Icon = ({ children, color, size }) => {
246
+ const style = {
247
+ width: typeof size === "number" ? size : void 0,
248
+ height: typeof size === "number" ? size : void 0,
249
+ alignItems: "center",
250
+ justifyContent: "center"
251
+ };
252
+ const childrenWithProps = import_react.default.Children.map(children, (child) => {
253
+ if (import_react.default.isValidElement(child)) {
254
+ return import_react.default.cloneElement(child, {
255
+ color: child.props.color || color,
256
+ // Also pass size if child seems to be an icon that needs it
257
+ size: child.props.size || size
258
+ });
259
+ }
260
+ return child;
261
+ });
262
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.View, { style, children: childrenWithProps });
263
+ };
264
+
265
+ // src/ToggleButtonGroup.tsx
266
+ var import_xui_core = require("@xsolla/xui-core");
267
+ var import_jsx_runtime4 = require("react/jsx-runtime");
268
+ var ToggleButtonGroup = ({
269
+ items,
270
+ value,
271
+ defaultValue,
272
+ onChange,
273
+ size = "md",
274
+ appearance = "separated",
275
+ multiple = false,
276
+ id,
277
+ testID,
278
+ "aria-label": ariaLabel,
279
+ "aria-labelledby": ariaLabelledBy
280
+ }) => {
281
+ const { theme } = (0, import_xui_core.useDesignSystem)();
282
+ const sizeStyles = theme.sizing.toggleButtonGroup(size);
283
+ const itemRefs = (0, import_react2.useRef)([]);
284
+ const [internalValue, setInternalValue] = (0, import_react2.useState)(() => {
285
+ if (defaultValue !== void 0) {
286
+ return Array.isArray(defaultValue) ? defaultValue : [defaultValue];
287
+ }
288
+ return [];
289
+ });
290
+ const currentValue = value !== void 0 ? Array.isArray(value) ? value : [value] : internalValue;
291
+ const isItemActive = (itemId) => currentValue.includes(itemId);
292
+ const enabledIndices = items.map((item, index) => !item.disabled ? index : -1).filter((i) => i !== -1);
293
+ const focusItem = (0, import_react2.useCallback)((index) => {
294
+ const element = itemRefs.current[index];
295
+ if (element) {
296
+ element.focus();
297
+ }
298
+ }, []);
299
+ const handleSelect = (0, import_react2.useCallback)(
300
+ (itemId) => {
301
+ let newValue;
302
+ if (multiple) {
303
+ if (currentValue.includes(itemId)) {
304
+ newValue = currentValue.filter((v) => v !== itemId);
305
+ } else {
306
+ newValue = [...currentValue, itemId];
307
+ }
308
+ } else {
309
+ newValue = [itemId];
310
+ }
311
+ if (value === void 0) {
312
+ setInternalValue(newValue);
313
+ }
314
+ if (onChange) {
315
+ if (multiple) {
316
+ onChange(newValue);
317
+ } else {
318
+ onChange(newValue[0] || "");
319
+ }
320
+ }
321
+ },
322
+ [currentValue, multiple, value, onChange]
323
+ );
324
+ const handleKeyDown = (0, import_react2.useCallback)(
325
+ (e, currentIndex) => {
326
+ const currentEnabledIndex = enabledIndices.indexOf(currentIndex);
327
+ switch (e.key) {
328
+ case "ArrowRight":
329
+ case "ArrowDown":
330
+ e.preventDefault();
331
+ {
332
+ const nextEnabledIndex = currentEnabledIndex < enabledIndices.length - 1 ? enabledIndices[currentEnabledIndex + 1] : enabledIndices[0];
333
+ focusItem(nextEnabledIndex);
334
+ }
335
+ break;
336
+ case "ArrowLeft":
337
+ case "ArrowUp":
338
+ e.preventDefault();
339
+ {
340
+ const prevEnabledIndex = currentEnabledIndex > 0 ? enabledIndices[currentEnabledIndex - 1] : enabledIndices[enabledIndices.length - 1];
341
+ focusItem(prevEnabledIndex);
342
+ }
343
+ break;
344
+ case "Enter":
345
+ case " ":
346
+ e.preventDefault();
347
+ if (!items[currentIndex].disabled) {
348
+ handleSelect(items[currentIndex].id);
349
+ }
350
+ break;
351
+ default:
352
+ break;
353
+ }
354
+ },
355
+ [enabledIndices, focusItem, handleSelect, items]
356
+ );
357
+ const isSeparated = appearance === "separated";
358
+ const containerGap = isSeparated ? sizeStyles.itemGap : 0;
359
+ const firstActiveIndex = items.findIndex(
360
+ (item) => currentValue.includes(item.id)
361
+ );
362
+ const firstEnabledIndex = enabledIndices[0] ?? 0;
363
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
364
+ Box,
365
+ {
366
+ id,
367
+ role: multiple ? "group" : "radiogroup",
368
+ "aria-label": ariaLabel,
369
+ "aria-labelledby": ariaLabelledBy,
370
+ testID,
371
+ flexDirection: "row",
372
+ alignItems: "center",
373
+ flexWrap: "wrap",
374
+ gap: containerGap,
375
+ ...!isSeparated && {
376
+ borderWidth: 1,
377
+ borderColor: theme.colors.control.toggleButton.border,
378
+ borderStyle: "solid",
379
+ borderRadius: sizeStyles.borderRadius,
380
+ width: "fit-content"
381
+ },
382
+ children: items.map((item, index) => {
383
+ const isActive = isItemActive(item.id);
384
+ const isDisabled = item.disabled;
385
+ const itemId = id ? `${id}-item-${item.id}` : void 0;
386
+ let tabIndex;
387
+ if (isDisabled) {
388
+ tabIndex = -1;
389
+ } else if (multiple) {
390
+ tabIndex = 0;
391
+ } else {
392
+ tabIndex = isActive || firstActiveIndex === -1 && index === firstEnabledIndex ? 0 : -1;
393
+ }
394
+ const handlePress = () => {
395
+ if (!isDisabled) {
396
+ handleSelect(item.id);
397
+ }
398
+ };
399
+ const toggleColors = theme.colors.control.toggleButton;
400
+ const bgColor = isDisabled ? toggleColors.bgDisable : isActive ? toggleColors.bgPress : toggleColors.bg;
401
+ const textColor = isDisabled ? toggleColors.textDisable : toggleColors.text;
402
+ const borderColor = isDisabled ? toggleColors.borderDisable : isActive ? toggleColors.borderPress : toggleColors.border;
403
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
404
+ Box,
405
+ {
406
+ as: "button",
407
+ role: multiple ? "checkbox" : "radio",
408
+ id: itemId,
409
+ "aria-checked": isActive,
410
+ "aria-disabled": isDisabled,
411
+ "aria-label": item["aria-label"] || item.label,
412
+ tabIndex,
413
+ disabled: isDisabled,
414
+ ref: (el) => {
415
+ itemRefs.current[index] = el;
416
+ },
417
+ onPress: handlePress,
418
+ onKeyDown: (e) => handleKeyDown(e, index),
419
+ height: sizeStyles.height,
420
+ paddingHorizontal: sizeStyles.paddingHorizontal,
421
+ flexDirection: "row",
422
+ alignItems: "center",
423
+ justifyContent: "center",
424
+ gap: sizeStyles.gap,
425
+ backgroundColor: bgColor,
426
+ ...isSeparated && {
427
+ borderWidth: 1,
428
+ borderColor,
429
+ borderStyle: "solid",
430
+ borderRadius: sizeStyles.borderRadius
431
+ },
432
+ cursor: isDisabled ? "not-allowed" : "pointer",
433
+ hoverStyle: !isDisabled && !isActive ? {
434
+ backgroundColor: toggleColors.bgHover,
435
+ borderColor: toggleColors.borderHover
436
+ } : void 0,
437
+ ...!isSeparated && {
438
+ borderLeftWidth: index > 0 ? 1 : 0,
439
+ borderLeftColor: theme.colors.control.toggleButton.border,
440
+ borderLeftStyle: "solid"
441
+ },
442
+ style: {
443
+ flexShrink: 0,
444
+ ...!isSeparated && index === 0 && {
445
+ borderTopLeftRadius: sizeStyles.borderRadius - 1,
446
+ borderBottomLeftRadius: sizeStyles.borderRadius - 1
447
+ },
448
+ ...!isSeparated && index === items.length - 1 && {
449
+ borderTopRightRadius: sizeStyles.borderRadius - 1,
450
+ borderBottomRightRadius: sizeStyles.borderRadius - 1
451
+ }
452
+ },
453
+ children: [
454
+ item.iconLeft && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { size: sizeStyles.iconSize, color: textColor, "aria-hidden": true, children: item.iconLeft }),
455
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
456
+ Text,
457
+ {
458
+ color: textColor,
459
+ fontSize: sizeStyles.fontSize,
460
+ fontWeight: "400",
461
+ textAlign: "center",
462
+ style: {
463
+ lineHeight: `${sizeStyles.lineHeight}px`
464
+ },
465
+ children: item.label
466
+ }
467
+ ),
468
+ item.iconRight && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { size: sizeStyles.iconSize, color: textColor, "aria-hidden": true, children: item.iconRight })
469
+ ]
470
+ },
471
+ item.id
472
+ );
473
+ })
474
+ }
475
+ );
476
+ };
477
+ ToggleButtonGroup.displayName = "ToggleButtonGroup";
478
+ // Annotate the CommonJS export names for ESM import in node:
479
+ 0 && (module.exports = {
480
+ ToggleButtonGroup
481
+ });
482
+ //# sourceMappingURL=index.js.map