@xsolla/xui-tabs-web 0.64.0-pr56.1768348754

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/index.js ADDED
@@ -0,0 +1,715 @@
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
+ TabPanel: () => TabPanel,
34
+ Tabs: () => Tabs
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+
38
+ // src/Tabs.tsx
39
+ var import_react4 = require("react");
40
+
41
+ // ../primitives-web/src/Box.tsx
42
+ var import_react = __toESM(require("react"));
43
+ var import_styled_components = __toESM(require("styled-components"));
44
+ var import_jsx_runtime = require("react/jsx-runtime");
45
+ var StyledBox = import_styled_components.default.div`
46
+ display: flex;
47
+ box-sizing: border-box;
48
+ background-color: ${(props) => props.backgroundColor || "transparent"};
49
+ border-color: ${(props) => props.borderColor || "transparent"};
50
+ border-width: ${(props) => typeof props.borderWidth === "number" ? `${props.borderWidth}px` : props.borderWidth || 0};
51
+
52
+ ${(props) => props.borderBottomWidth !== void 0 && `
53
+ border-bottom-width: ${typeof props.borderBottomWidth === "number" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};
54
+ border-bottom-color: ${props.borderBottomColor || props.borderColor || "transparent"};
55
+ border-bottom-style: solid;
56
+ `}
57
+ ${(props) => props.borderTopWidth !== void 0 && `
58
+ border-top-width: ${typeof props.borderTopWidth === "number" ? `${props.borderTopWidth}px` : props.borderTopWidth};
59
+ border-top-color: ${props.borderTopColor || props.borderColor || "transparent"};
60
+ border-top-style: solid;
61
+ `}
62
+ ${(props) => props.borderLeftWidth !== void 0 && `
63
+ border-left-width: ${typeof props.borderLeftWidth === "number" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};
64
+ border-left-color: ${props.borderLeftColor || props.borderColor || "transparent"};
65
+ border-left-style: solid;
66
+ `}
67
+ ${(props) => props.borderRightWidth !== void 0 && `
68
+ border-right-width: ${typeof props.borderRightWidth === "number" ? `${props.borderRightWidth}px` : props.borderRightWidth};
69
+ border-right-color: ${props.borderRightColor || props.borderColor || "transparent"};
70
+ border-right-style: solid;
71
+ `}
72
+
73
+ border-style: ${(props) => props.borderStyle || (props.borderWidth || props.borderBottomWidth || props.borderTopWidth || props.borderLeftWidth || props.borderRightWidth ? "solid" : "none")};
74
+ border-radius: ${(props) => typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius || 0};
75
+ height: ${(props) => typeof props.height === "number" ? `${props.height}px` : props.height || "auto"};
76
+ width: ${(props) => typeof props.width === "number" ? `${props.width}px` : props.width || "auto"};
77
+ min-width: ${(props) => typeof props.minWidth === "number" ? `${props.minWidth}px` : props.minWidth || "auto"};
78
+ min-height: ${(props) => typeof props.minHeight === "number" ? `${props.minHeight}px` : props.minHeight || "auto"};
79
+
80
+ padding: ${(props) => typeof props.padding === "number" ? `${props.padding}px` : props.padding || 0};
81
+ ${(props) => props.paddingHorizontal && `
82
+ padding-left: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
83
+ padding-right: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
84
+ `}
85
+ ${(props) => props.paddingVertical && `
86
+ padding-top: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
87
+ padding-bottom: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
88
+ `}
89
+ ${(props) => props.paddingTop !== void 0 && `padding-top: ${typeof props.paddingTop === "number" ? `${props.paddingTop}px` : props.paddingTop};`}
90
+ ${(props) => props.paddingBottom !== void 0 && `padding-bottom: ${typeof props.paddingBottom === "number" ? `${props.paddingBottom}px` : props.paddingBottom};`}
91
+ ${(props) => props.paddingLeft !== void 0 && `padding-left: ${typeof props.paddingLeft === "number" ? `${props.paddingLeft}px` : props.paddingLeft};`}
92
+ ${(props) => props.paddingRight !== void 0 && `padding-right: ${typeof props.paddingRight === "number" ? `${props.paddingRight}px` : props.paddingRight};`}
93
+
94
+ margin: ${(props) => typeof props.margin === "number" ? `${props.margin}px` : props.margin || 0};
95
+ ${(props) => props.marginTop !== void 0 && `margin-top: ${typeof props.marginTop === "number" ? `${props.marginTop}px` : props.marginTop};`}
96
+ ${(props) => props.marginBottom !== void 0 && `margin-bottom: ${typeof props.marginBottom === "number" ? `${props.marginBottom}px` : props.marginBottom};`}
97
+ ${(props) => props.marginLeft !== void 0 && `margin-left: ${typeof props.marginLeft === "number" ? `${props.marginLeft}px` : props.marginLeft};`}
98
+ ${(props) => props.marginRight !== void 0 && `margin-right: ${typeof props.marginRight === "number" ? `${props.marginRight}px` : props.marginRight};`}
99
+
100
+ flex-direction: ${(props) => props.flexDirection || "column"};
101
+ flex-wrap: ${(props) => props.flexWrap || "nowrap"};
102
+ align-items: ${(props) => props.alignItems || "stretch"};
103
+ justify-content: ${(props) => props.justifyContent || "flex-start"};
104
+ cursor: ${(props) => props.cursor ? props.cursor : props.onClick || props.onPress ? "pointer" : "inherit"};
105
+ position: ${(props) => props.position || "static"};
106
+ top: ${(props) => typeof props.top === "number" ? `${props.top}px` : props.top};
107
+ bottom: ${(props) => typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom};
108
+ left: ${(props) => typeof props.left === "number" ? `${props.left}px` : props.left};
109
+ right: ${(props) => typeof props.right === "number" ? `${props.right}px` : props.right};
110
+ flex: ${(props) => props.flex};
111
+ flex-shrink: ${(props) => props.flexShrink ?? 1};
112
+ gap: ${(props) => typeof props.gap === "number" ? `${props.gap}px` : props.gap || 0};
113
+ align-self: ${(props) => props.alignSelf || "auto"};
114
+ overflow: ${(props) => props.overflow || "visible"};
115
+ overflow-x: ${(props) => props.overflowX || "visible"};
116
+ overflow-y: ${(props) => props.overflowY || "visible"};
117
+ z-index: ${(props) => props.zIndex};
118
+ opacity: ${(props) => props.disabled ? 0.5 : 1};
119
+ pointer-events: ${(props) => props.disabled ? "none" : "auto"};
120
+
121
+ &:hover {
122
+ ${(props) => props.hoverStyle?.backgroundColor && `background-color: ${props.hoverStyle.backgroundColor};`}
123
+ ${(props) => props.hoverStyle?.borderColor && `border-color: ${props.hoverStyle.borderColor};`}
124
+ }
125
+
126
+ &:active {
127
+ ${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
128
+ }
129
+ `;
130
+ var Box = import_react.default.forwardRef(
131
+ ({
132
+ children,
133
+ onPress,
134
+ onKeyDown,
135
+ onKeyUp,
136
+ role,
137
+ "aria-label": ariaLabel,
138
+ "aria-labelledby": ariaLabelledBy,
139
+ "aria-current": ariaCurrent,
140
+ "aria-disabled": ariaDisabled,
141
+ "aria-live": ariaLive,
142
+ "aria-busy": ariaBusy,
143
+ "aria-describedby": ariaDescribedBy,
144
+ "aria-expanded": ariaExpanded,
145
+ "aria-haspopup": ariaHasPopup,
146
+ "aria-pressed": ariaPressed,
147
+ "aria-controls": ariaControls,
148
+ tabIndex,
149
+ as,
150
+ src,
151
+ alt,
152
+ type,
153
+ disabled,
154
+ id,
155
+ ...props
156
+ }, ref) => {
157
+ if (as === "img" && src) {
158
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
159
+ "img",
160
+ {
161
+ src,
162
+ alt: alt || "",
163
+ style: {
164
+ display: "block",
165
+ objectFit: "cover",
166
+ width: typeof props.width === "number" ? `${props.width}px` : props.width,
167
+ height: typeof props.height === "number" ? `${props.height}px` : props.height,
168
+ borderRadius: typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius,
169
+ position: props.position,
170
+ top: typeof props.top === "number" ? `${props.top}px` : props.top,
171
+ left: typeof props.left === "number" ? `${props.left}px` : props.left,
172
+ right: typeof props.right === "number" ? `${props.right}px` : props.right,
173
+ bottom: typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom
174
+ }
175
+ }
176
+ );
177
+ }
178
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
179
+ StyledBox,
180
+ {
181
+ ref,
182
+ as,
183
+ id,
184
+ type: as === "button" ? type || "button" : void 0,
185
+ disabled: as === "button" ? disabled : void 0,
186
+ onClick: onPress,
187
+ onKeyDown,
188
+ onKeyUp,
189
+ role,
190
+ "aria-label": ariaLabel,
191
+ "aria-labelledby": ariaLabelledBy,
192
+ "aria-current": ariaCurrent,
193
+ "aria-disabled": ariaDisabled,
194
+ "aria-busy": ariaBusy,
195
+ "aria-describedby": ariaDescribedBy,
196
+ "aria-expanded": ariaExpanded,
197
+ "aria-haspopup": ariaHasPopup,
198
+ "aria-pressed": ariaPressed,
199
+ "aria-controls": ariaControls,
200
+ "aria-live": ariaLive,
201
+ tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
202
+ ...props,
203
+ children
204
+ }
205
+ );
206
+ }
207
+ );
208
+ Box.displayName = "Box";
209
+
210
+ // ../primitives-web/src/Text.tsx
211
+ var import_styled_components2 = __toESM(require("styled-components"));
212
+ var import_jsx_runtime2 = require("react/jsx-runtime");
213
+ var StyledText = import_styled_components2.default.span`
214
+ color: ${(props) => props.color || "inherit"};
215
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
216
+ font-weight: ${(props) => props.fontWeight || "normal"};
217
+ font-family: ${(props) => props.fontFamily || '"Pilat Wide Bold", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important'};
218
+ line-height: ${(props) => typeof props.lineHeight === "number" ? `${props.lineHeight}px` : props.lineHeight || "inherit"};
219
+ white-space: ${(props) => props.whiteSpace || "normal"};
220
+ text-align: ${(props) => props.textAlign || "inherit"};
221
+ text-decoration: ${(props) => props.textDecoration || "none"};
222
+ `;
223
+ var Text = ({
224
+ style,
225
+ className,
226
+ id,
227
+ role,
228
+ ...props
229
+ }) => {
230
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
231
+ StyledText,
232
+ {
233
+ ...props,
234
+ style,
235
+ className,
236
+ id,
237
+ role
238
+ }
239
+ );
240
+ };
241
+
242
+ // ../primitives-web/src/Spinner.tsx
243
+ var import_styled_components3 = __toESM(require("styled-components"));
244
+ var import_jsx_runtime3 = require("react/jsx-runtime");
245
+ var rotate = import_styled_components3.keyframes`
246
+ from {
247
+ transform: rotate(0deg);
248
+ }
249
+ to {
250
+ transform: rotate(360deg);
251
+ }
252
+ `;
253
+ var StyledSpinner = import_styled_components3.default.div`
254
+ width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
255
+ height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
256
+ border: ${(props) => props.strokeWidth || 2}px solid
257
+ ${(props) => props.color || "currentColor"};
258
+ border-bottom-color: transparent;
259
+ border-radius: 50%;
260
+ display: inline-block;
261
+ box-sizing: border-box;
262
+ animation: ${rotate} 1s linear infinite;
263
+ `;
264
+ var Spinner = ({
265
+ role = "status",
266
+ "aria-label": ariaLabel,
267
+ "aria-live": ariaLive = "polite",
268
+ "aria-describedby": ariaDescribedBy,
269
+ testID,
270
+ ...props
271
+ }) => {
272
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
273
+ StyledSpinner,
274
+ {
275
+ role,
276
+ "aria-label": ariaLabel,
277
+ "aria-live": ariaLive,
278
+ "aria-describedby": ariaDescribedBy,
279
+ "data-testid": testID,
280
+ ...props
281
+ }
282
+ );
283
+ };
284
+ Spinner.displayName = "Spinner";
285
+
286
+ // ../primitives-web/src/Icon.tsx
287
+ var import_styled_components4 = __toESM(require("styled-components"));
288
+ var import_jsx_runtime4 = require("react/jsx-runtime");
289
+ var StyledIcon = import_styled_components4.default.div`
290
+ display: flex;
291
+ align-items: center;
292
+ justify-content: center;
293
+ width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
294
+ height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
295
+ color: ${(props) => props.color || "currentColor"};
296
+
297
+ svg {
298
+ width: 100%;
299
+ height: 100%;
300
+ fill: none;
301
+ stroke: currentColor;
302
+ }
303
+ `;
304
+ var Icon = ({ children, ...props }) => {
305
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StyledIcon, { ...props, children });
306
+ };
307
+
308
+ // ../primitives-web/src/Divider.tsx
309
+ var import_styled_components5 = __toESM(require("styled-components"));
310
+ var import_jsx_runtime5 = require("react/jsx-runtime");
311
+ var StyledDivider = import_styled_components5.default.div`
312
+ background-color: ${(props) => props.dashStroke ? "transparent" : props.color || "rgba(255, 255, 255, 0.15)"};
313
+ width: ${(props) => props.vertical ? typeof props.width === "number" ? `${props.width}px` : props.width || "1px" : "100%"};
314
+ height: ${(props) => props.vertical ? "100%" : typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
315
+
316
+ ${(props) => props.dashStroke && `
317
+ border-style: dashed;
318
+ border-color: ${props.color || "rgba(255, 255, 255, 0.15)"};
319
+ border-width: 0;
320
+ ${props.vertical ? `
321
+ border-left-width: ${typeof props.width === "number" ? `${props.width}px` : props.width || "1px"};
322
+ height: 100%;
323
+ ` : `
324
+ border-top-width: ${typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
325
+ width: 100%;
326
+ `}
327
+ `}
328
+ `;
329
+
330
+ // ../primitives-web/src/Input.tsx
331
+ var import_react2 = require("react");
332
+ var import_styled_components6 = __toESM(require("styled-components"));
333
+ var import_jsx_runtime6 = require("react/jsx-runtime");
334
+ var StyledInput = import_styled_components6.default.input`
335
+ background: transparent;
336
+ border: none;
337
+ outline: none;
338
+ width: 100%;
339
+ height: 100%;
340
+ padding: 0;
341
+ margin: 0;
342
+ color: ${(props) => props.color || "inherit"};
343
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
344
+ font-family: inherit;
345
+ text-align: inherit;
346
+
347
+ &::placeholder {
348
+ color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
349
+ }
350
+
351
+ &:disabled {
352
+ cursor: not-allowed;
353
+ }
354
+ `;
355
+ var InputPrimitive = (0, import_react2.forwardRef)(
356
+ ({
357
+ value,
358
+ placeholder,
359
+ onChange,
360
+ onChangeText,
361
+ onFocus,
362
+ onBlur,
363
+ onKeyDown,
364
+ disabled,
365
+ secureTextEntry,
366
+ style,
367
+ color,
368
+ fontSize,
369
+ placeholderTextColor,
370
+ maxLength,
371
+ name,
372
+ type,
373
+ inputMode,
374
+ autoComplete,
375
+ id,
376
+ "aria-invalid": ariaInvalid,
377
+ "aria-describedby": ariaDescribedBy,
378
+ "aria-labelledby": ariaLabelledBy,
379
+ "aria-label": ariaLabel,
380
+ "aria-disabled": ariaDisabled,
381
+ "data-testid": dataTestId,
382
+ ...rest
383
+ }, ref) => {
384
+ const handleChange = (e) => {
385
+ if (onChange) {
386
+ onChange(e);
387
+ }
388
+ if (onChangeText) {
389
+ onChangeText(e.target.value);
390
+ }
391
+ };
392
+ const inputValue = value !== void 0 ? value : "";
393
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
394
+ StyledInput,
395
+ {
396
+ ref,
397
+ id,
398
+ value: inputValue,
399
+ name,
400
+ placeholder,
401
+ onChange: handleChange,
402
+ onFocus,
403
+ onBlur,
404
+ onKeyDown,
405
+ disabled,
406
+ type: secureTextEntry ? "password" : type || "text",
407
+ inputMode,
408
+ autoComplete,
409
+ style,
410
+ color,
411
+ fontSize,
412
+ placeholderTextColor,
413
+ maxLength,
414
+ "aria-invalid": ariaInvalid,
415
+ "aria-describedby": ariaDescribedBy,
416
+ "aria-labelledby": ariaLabelledBy,
417
+ "aria-label": ariaLabel,
418
+ "aria-disabled": ariaDisabled,
419
+ "data-testid": dataTestId,
420
+ ...rest
421
+ }
422
+ );
423
+ }
424
+ );
425
+ InputPrimitive.displayName = "InputPrimitive";
426
+
427
+ // ../primitives-web/src/TextArea.tsx
428
+ var import_react3 = require("react");
429
+ var import_styled_components7 = __toESM(require("styled-components"));
430
+ var import_jsx_runtime7 = require("react/jsx-runtime");
431
+ var StyledTextArea = import_styled_components7.default.textarea`
432
+ background: transparent;
433
+ border: none;
434
+ outline: none;
435
+ width: 100%;
436
+ height: 100%;
437
+ padding: 0;
438
+ margin: 0;
439
+ color: ${(props) => props.color || "inherit"};
440
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
441
+ font-family: inherit;
442
+ text-align: inherit;
443
+ resize: none;
444
+
445
+ &::placeholder {
446
+ color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
447
+ }
448
+
449
+ &:disabled {
450
+ cursor: not-allowed;
451
+ }
452
+ `;
453
+ var TextAreaPrimitive = (0, import_react3.forwardRef)(
454
+ ({
455
+ value,
456
+ placeholder,
457
+ onChangeText,
458
+ onFocus,
459
+ onBlur,
460
+ onKeyDown,
461
+ disabled,
462
+ style,
463
+ color,
464
+ fontSize,
465
+ placeholderTextColor,
466
+ maxLength,
467
+ rows
468
+ }, ref) => {
469
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
470
+ StyledTextArea,
471
+ {
472
+ ref,
473
+ value,
474
+ placeholder,
475
+ onChange: (e) => onChangeText?.(e.target.value),
476
+ onFocus,
477
+ onBlur,
478
+ onKeyDown,
479
+ disabled,
480
+ style,
481
+ color,
482
+ fontSize,
483
+ placeholderTextColor,
484
+ maxLength,
485
+ rows
486
+ }
487
+ );
488
+ }
489
+ );
490
+ TextAreaPrimitive.displayName = "TextAreaPrimitive";
491
+
492
+ // src/Tabs.tsx
493
+ var import_xui_core = require("@xsolla/xui-core");
494
+ var import_xui_badge = require("@xsolla/xui-badge");
495
+ var import_jsx_runtime8 = require("react/jsx-runtime");
496
+ var Tabs = ({
497
+ tabs,
498
+ activeTabId,
499
+ onChange,
500
+ size = "m",
501
+ alignLeft = true,
502
+ "aria-label": ariaLabel,
503
+ "aria-labelledby": ariaLabelledBy,
504
+ activateOnFocus = true,
505
+ id,
506
+ testID
507
+ }) => {
508
+ const { theme } = (0, import_xui_core.useDesignSystem)();
509
+ const sizeStyles = theme.sizing.tabs(size);
510
+ const tabListId = id ? `${id}-tablist` : void 0;
511
+ const [_focusedIndex, setFocusedIndex] = (0, import_react4.useState)(-1);
512
+ const tabRefs = (0, import_react4.useRef)([]);
513
+ const enabledIndices = tabs.map((tab, index) => !tab.disabled ? index : -1).filter((i) => i !== -1);
514
+ const focusTab = (0, import_react4.useCallback)((index) => {
515
+ const tabElement = tabRefs.current[index];
516
+ if (tabElement) {
517
+ tabElement.focus();
518
+ setFocusedIndex(index);
519
+ }
520
+ }, []);
521
+ const handleKeyDown = (0, import_react4.useCallback)(
522
+ (e, currentIndex) => {
523
+ const currentEnabledIndex = enabledIndices.indexOf(currentIndex);
524
+ switch (e.key) {
525
+ case "ArrowRight":
526
+ case "ArrowDown":
527
+ e.preventDefault();
528
+ {
529
+ const nextEnabledIndex = currentEnabledIndex < enabledIndices.length - 1 ? enabledIndices[currentEnabledIndex + 1] : enabledIndices[0];
530
+ focusTab(nextEnabledIndex);
531
+ if (activateOnFocus && onChange) {
532
+ onChange(tabs[nextEnabledIndex].id);
533
+ }
534
+ }
535
+ break;
536
+ case "ArrowLeft":
537
+ case "ArrowUp":
538
+ e.preventDefault();
539
+ {
540
+ const prevEnabledIndex = currentEnabledIndex > 0 ? enabledIndices[currentEnabledIndex - 1] : enabledIndices[enabledIndices.length - 1];
541
+ focusTab(prevEnabledIndex);
542
+ if (activateOnFocus && onChange) {
543
+ onChange(tabs[prevEnabledIndex].id);
544
+ }
545
+ }
546
+ break;
547
+ case "Home":
548
+ e.preventDefault();
549
+ {
550
+ const firstEnabledIndex = enabledIndices[0];
551
+ focusTab(firstEnabledIndex);
552
+ if (activateOnFocus && onChange) {
553
+ onChange(tabs[firstEnabledIndex].id);
554
+ }
555
+ }
556
+ break;
557
+ case "End":
558
+ e.preventDefault();
559
+ {
560
+ const lastEnabledIndex = enabledIndices[enabledIndices.length - 1];
561
+ focusTab(lastEnabledIndex);
562
+ if (activateOnFocus && onChange) {
563
+ onChange(tabs[lastEnabledIndex].id);
564
+ }
565
+ }
566
+ break;
567
+ case "Enter":
568
+ case " ":
569
+ e.preventDefault();
570
+ if (!activateOnFocus && onChange) {
571
+ onChange(tabs[currentIndex].id);
572
+ }
573
+ break;
574
+ default:
575
+ break;
576
+ }
577
+ },
578
+ [enabledIndices, focusTab, activateOnFocus, onChange, tabs]
579
+ );
580
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
581
+ Box,
582
+ {
583
+ as: "nav",
584
+ role: "tablist",
585
+ id: tabListId,
586
+ "aria-label": ariaLabel,
587
+ "aria-labelledby": ariaLabelledBy,
588
+ "aria-orientation": "horizontal",
589
+ testID,
590
+ flexDirection: "row",
591
+ alignItems: "flex-end",
592
+ justifyContent: alignLeft ? "flex-start" : "center",
593
+ width: "100%",
594
+ height: sizeStyles.height,
595
+ borderBottomWidth: 1,
596
+ borderBottomColor: theme.colors.border.secondary,
597
+ borderStyle: "solid",
598
+ children: tabs.map((tab, index) => {
599
+ const isActive = tab.id === activeTabId;
600
+ const isDisabled = tab.disabled;
601
+ const tabId = `${id}-tab-${tab.id}`;
602
+ const tabPanelId = `${id}-tabpanel-${tab.id}`;
603
+ const handlePress = () => {
604
+ if (!isDisabled && onChange) {
605
+ onChange(tab.id);
606
+ }
607
+ };
608
+ const handleFocus = () => {
609
+ setFocusedIndex(index);
610
+ };
611
+ const textColor = isDisabled ? theme.colors.content.tertiary : isActive ? theme.colors.content.primary : theme.colors.content.tertiary;
612
+ const borderBottomColor = isActive ? theme.colors.border.primary : "transparent";
613
+ const borderBottomWidth = isActive ? 2 : 0;
614
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
615
+ Box,
616
+ {
617
+ as: "button",
618
+ role: "tab",
619
+ id: tabId,
620
+ "aria-selected": isActive,
621
+ "aria-disabled": isDisabled,
622
+ "aria-controls": tabPanelId,
623
+ "aria-label": tab["aria-label"],
624
+ tabIndex: isActive ? 0 : -1,
625
+ disabled: isDisabled,
626
+ ref: (el) => {
627
+ tabRefs.current[index] = el;
628
+ },
629
+ onPress: handlePress,
630
+ onFocus: handleFocus,
631
+ onKeyDown: (e) => handleKeyDown(e, index),
632
+ height: sizeStyles.height,
633
+ paddingHorizontal: sizeStyles.paddingHorizontal,
634
+ flexDirection: "row",
635
+ alignItems: "center",
636
+ justifyContent: "center",
637
+ gap: sizeStyles.gap,
638
+ position: "relative",
639
+ borderBottomWidth,
640
+ borderBottomColor,
641
+ borderStyle: isActive ? "solid" : "none",
642
+ marginBottom: -1,
643
+ cursor: isDisabled ? "not-allowed" : "pointer",
644
+ hoverStyle: !isDisabled && !isActive ? {
645
+ backgroundColor: theme.colors.overlay.mono
646
+ } : void 0,
647
+ focusStyle: {
648
+ outlineColor: theme.colors.border.brand,
649
+ outlineWidth: 2,
650
+ outlineOffset: -2
651
+ },
652
+ children: [
653
+ tab.icon && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { size: sizeStyles.iconSize, color: textColor, "aria-hidden": true, children: tab.icon }),
654
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
655
+ Text,
656
+ {
657
+ color: textColor,
658
+ fontSize: sizeStyles.fontSize,
659
+ fontWeight: isActive ? "600" : "500",
660
+ children: tab.label
661
+ }
662
+ ),
663
+ tab.counter !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { marginLeft: 2, "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
664
+ Text,
665
+ {
666
+ color: theme.colors.content.brand.primary,
667
+ fontSize: sizeStyles.fontSize,
668
+ fontWeight: "500",
669
+ "aria-label": `${tab.counter} items`,
670
+ children: tab.counter
671
+ }
672
+ ) }),
673
+ tab.badge && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { marginLeft: 2, "aria-hidden": true, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_xui_badge.Badge, { size: "s", children: typeof tab.badge === "string" || typeof tab.badge === "number" ? tab.badge : void 0 }) })
674
+ ]
675
+ },
676
+ tab.id
677
+ );
678
+ })
679
+ }
680
+ );
681
+ };
682
+ Tabs.displayName = "Tabs";
683
+ var TabPanel = ({
684
+ id,
685
+ tabsId,
686
+ hidden = false,
687
+ children,
688
+ "aria-label": ariaLabel,
689
+ testID
690
+ }) => {
691
+ const panelId = `${tabsId}-tabpanel-${id}`;
692
+ const tabId = `${tabsId}-tab-${id}`;
693
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
694
+ Box,
695
+ {
696
+ as: "section",
697
+ role: "tabpanel",
698
+ id: panelId,
699
+ "aria-labelledby": tabId,
700
+ "aria-label": ariaLabel,
701
+ "aria-hidden": hidden,
702
+ tabIndex: hidden ? -1 : 0,
703
+ testID,
704
+ style: { display: hidden ? "none" : void 0 },
705
+ children
706
+ }
707
+ );
708
+ };
709
+ TabPanel.displayName = "TabPanel";
710
+ // Annotate the CommonJS export names for ESM import in node:
711
+ 0 && (module.exports = {
712
+ TabPanel,
713
+ Tabs
714
+ });
715
+ //# sourceMappingURL=index.js.map