@dxc-technology/halstack-react 15.1.0 → 15.1.1
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/dist/index.d.mts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/index.js +32 -27
- package/dist/index.mjs +32 -27
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3048,7 +3048,7 @@ type TabCommonProps = {
|
|
|
3048
3048
|
*/
|
|
3049
3049
|
notificationNumber?: boolean | number;
|
|
3050
3050
|
};
|
|
3051
|
-
type TabLabelProps =
|
|
3051
|
+
type TabLabelProps = {
|
|
3052
3052
|
/**
|
|
3053
3053
|
* Tab label.
|
|
3054
3054
|
*/
|
|
@@ -3058,7 +3058,7 @@ type TabLabelProps = TabCommonProps & {
|
|
|
3058
3058
|
*/
|
|
3059
3059
|
icon?: string | SVG;
|
|
3060
3060
|
};
|
|
3061
|
-
type TabIconProps =
|
|
3061
|
+
type TabIconProps = {
|
|
3062
3062
|
/**
|
|
3063
3063
|
* Tab label.
|
|
3064
3064
|
*/
|
|
@@ -3071,15 +3071,14 @@ type TabIconProps = TabCommonProps & {
|
|
|
3071
3071
|
type TabProps = {
|
|
3072
3072
|
defaultActive?: boolean;
|
|
3073
3073
|
active?: boolean;
|
|
3074
|
-
icon?: string | SVG;
|
|
3075
|
-
label: string;
|
|
3076
3074
|
title?: string;
|
|
3075
|
+
tabId?: string;
|
|
3077
3076
|
disabled?: boolean;
|
|
3078
3077
|
notificationNumber?: boolean | number;
|
|
3079
3078
|
children: ReactNode;
|
|
3080
3079
|
onClick?: () => void;
|
|
3081
3080
|
onHover?: () => void;
|
|
3082
|
-
};
|
|
3081
|
+
} & (TabLabelProps | TabIconProps);
|
|
3083
3082
|
type LegacyProps = {
|
|
3084
3083
|
/**
|
|
3085
3084
|
* Initially active tab, only when it is uncontrolled.
|
|
@@ -3093,7 +3092,7 @@ type LegacyProps = {
|
|
|
3093
3092
|
/**
|
|
3094
3093
|
* An array of objects representing the tabs.
|
|
3095
3094
|
*/
|
|
3096
|
-
tabs?: (TabLabelProps | TabIconProps)[];
|
|
3095
|
+
tabs?: (TabCommonProps & (TabLabelProps | TabIconProps))[];
|
|
3097
3096
|
/**
|
|
3098
3097
|
* Whether the icon should appear above or to the left of the label.
|
|
3099
3098
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -3048,7 +3048,7 @@ type TabCommonProps = {
|
|
|
3048
3048
|
*/
|
|
3049
3049
|
notificationNumber?: boolean | number;
|
|
3050
3050
|
};
|
|
3051
|
-
type TabLabelProps =
|
|
3051
|
+
type TabLabelProps = {
|
|
3052
3052
|
/**
|
|
3053
3053
|
* Tab label.
|
|
3054
3054
|
*/
|
|
@@ -3058,7 +3058,7 @@ type TabLabelProps = TabCommonProps & {
|
|
|
3058
3058
|
*/
|
|
3059
3059
|
icon?: string | SVG;
|
|
3060
3060
|
};
|
|
3061
|
-
type TabIconProps =
|
|
3061
|
+
type TabIconProps = {
|
|
3062
3062
|
/**
|
|
3063
3063
|
* Tab label.
|
|
3064
3064
|
*/
|
|
@@ -3071,15 +3071,14 @@ type TabIconProps = TabCommonProps & {
|
|
|
3071
3071
|
type TabProps = {
|
|
3072
3072
|
defaultActive?: boolean;
|
|
3073
3073
|
active?: boolean;
|
|
3074
|
-
icon?: string | SVG;
|
|
3075
|
-
label: string;
|
|
3076
3074
|
title?: string;
|
|
3075
|
+
tabId?: string;
|
|
3077
3076
|
disabled?: boolean;
|
|
3078
3077
|
notificationNumber?: boolean | number;
|
|
3079
3078
|
children: ReactNode;
|
|
3080
3079
|
onClick?: () => void;
|
|
3081
3080
|
onHover?: () => void;
|
|
3082
|
-
};
|
|
3081
|
+
} & (TabLabelProps | TabIconProps);
|
|
3083
3082
|
type LegacyProps = {
|
|
3084
3083
|
/**
|
|
3085
3084
|
* Initially active tab, only when it is uncontrolled.
|
|
@@ -3093,7 +3092,7 @@ type LegacyProps = {
|
|
|
3093
3092
|
/**
|
|
3094
3093
|
* An array of objects representing the tabs.
|
|
3095
3094
|
*/
|
|
3096
|
-
tabs?: (TabLabelProps | TabIconProps)[];
|
|
3095
|
+
tabs?: (TabCommonProps & (TabLabelProps | TabIconProps))[];
|
|
3097
3096
|
/**
|
|
3098
3097
|
* Whether the icon should appear above or to the left of the label.
|
|
3099
3098
|
*/
|
package/dist/index.js
CHANGED
|
@@ -12478,6 +12478,7 @@ var DxcTab2 = (0, import_react72.forwardRef)(
|
|
|
12478
12478
|
icon,
|
|
12479
12479
|
label,
|
|
12480
12480
|
title,
|
|
12481
|
+
tabId = label,
|
|
12481
12482
|
disabled = false,
|
|
12482
12483
|
active,
|
|
12483
12484
|
notificationNumber = false,
|
|
@@ -12490,30 +12491,30 @@ var DxcTab2 = (0, import_react72.forwardRef)(
|
|
|
12490
12491
|
const {
|
|
12491
12492
|
iconPosition = "top",
|
|
12492
12493
|
tabIndex = 0,
|
|
12493
|
-
|
|
12494
|
+
focusedTab,
|
|
12494
12495
|
isControlled,
|
|
12495
|
-
|
|
12496
|
+
activeTab,
|
|
12496
12497
|
hasLabelAndIcon = false,
|
|
12497
|
-
|
|
12498
|
+
setActiveTab,
|
|
12498
12499
|
setActiveIndicatorWidth,
|
|
12499
12500
|
setActiveIndicatorLeft
|
|
12500
12501
|
} = (0, import_react72.useContext)(TabsContext_default) ?? {};
|
|
12501
12502
|
(0, import_react72.useEffect)(() => {
|
|
12502
|
-
if (
|
|
12503
|
+
if (focusedTab === tabId) {
|
|
12503
12504
|
tabRef?.current?.focus();
|
|
12504
12505
|
}
|
|
12505
|
-
}, [
|
|
12506
|
+
}, [focusedTab, tabId]);
|
|
12506
12507
|
(0, import_react72.useEffect)(() => {
|
|
12507
|
-
if (
|
|
12508
|
+
if (activeTab === tabId) {
|
|
12508
12509
|
setActiveIndicatorWidth?.(tabRef.current?.offsetWidth ?? 0);
|
|
12509
12510
|
setActiveIndicatorLeft?.(tabRef.current?.offsetLeft ?? 0);
|
|
12510
12511
|
}
|
|
12511
|
-
}, [
|
|
12512
|
+
}, [activeTab, tabId, setActiveIndicatorWidth, setActiveIndicatorLeft]);
|
|
12512
12513
|
(0, import_react72.useEffect)(() => {
|
|
12513
12514
|
if (active) {
|
|
12514
|
-
|
|
12515
|
+
setActiveTab?.(tabId ?? label ?? "");
|
|
12515
12516
|
}
|
|
12516
|
-
}, [active, label,
|
|
12517
|
+
}, [active, label, setActiveTab]);
|
|
12517
12518
|
const handleOnKeyDown = (event) => {
|
|
12518
12519
|
switch (event.key) {
|
|
12519
12520
|
case " ":
|
|
@@ -12530,9 +12531,10 @@ var DxcTab2 = (0, import_react72.forwardRef)(
|
|
|
12530
12531
|
{
|
|
12531
12532
|
role: "tab",
|
|
12532
12533
|
type: "button",
|
|
12533
|
-
tabIndex:
|
|
12534
|
+
tabIndex: activeTab === tabId && !disabled ? tabIndex : -1,
|
|
12534
12535
|
disabled,
|
|
12535
|
-
"aria-
|
|
12536
|
+
"aria-label": label ?? tabId ?? "tab",
|
|
12537
|
+
"aria-selected": activeTab === tabId,
|
|
12536
12538
|
hasLabelAndIcon,
|
|
12537
12539
|
iconPosition,
|
|
12538
12540
|
ref: (anchorRef) => {
|
|
@@ -12548,7 +12550,8 @@ var DxcTab2 = (0, import_react72.forwardRef)(
|
|
|
12548
12550
|
},
|
|
12549
12551
|
onClick: () => {
|
|
12550
12552
|
if (!isControlled) {
|
|
12551
|
-
|
|
12553
|
+
setActiveTab?.(tabId ?? "");
|
|
12554
|
+
console.log(tabId);
|
|
12552
12555
|
}
|
|
12553
12556
|
onClick();
|
|
12554
12557
|
},
|
|
@@ -12564,7 +12567,7 @@ var DxcTab2 = (0, import_react72.forwardRef)(
|
|
|
12564
12567
|
disabled,
|
|
12565
12568
|
children: [
|
|
12566
12569
|
icon && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(TabIconContainer2, { hasLabelAndIcon, iconPosition, children: typeof icon === "string" ? /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Icon_default, { icon }) : icon }),
|
|
12567
|
-
/* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Label11, { disabled,
|
|
12570
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(Label11, { disabled, active: activeTab === tabId, label, children: label })
|
|
12568
12571
|
]
|
|
12569
12572
|
}
|
|
12570
12573
|
),
|
|
@@ -12656,7 +12659,7 @@ var MainLabelContainer = import_styled_components67.default.div`
|
|
|
12656
12659
|
`;
|
|
12657
12660
|
var Label11 = import_styled_components67.default.span`
|
|
12658
12661
|
display: inline;
|
|
12659
|
-
color: ${(props) => props.disabled ? props.theme.disabledFontColor : props.
|
|
12662
|
+
color: ${(props) => props.disabled ? props.theme.disabledFontColor : props.active ? props.theme.selectedFontColor : props.theme.unselectedFontColor};
|
|
12660
12663
|
font-family: ${(props) => props.theme.fontFamily};
|
|
12661
12664
|
font-size: ${(props) => props.theme.fontSize};
|
|
12662
12665
|
font-style: ${(props) => props.disabled ? props.theme.disabledFontStyle : props.theme.fontStyle};
|
|
@@ -13251,14 +13254,14 @@ var DxcTabs2 = ({
|
|
|
13251
13254
|
() => childrenArray.some((child) => (0, import_react75.isValidElement)(child) && child.props.icon && child.props.label),
|
|
13252
13255
|
[childrenArray]
|
|
13253
13256
|
);
|
|
13254
|
-
const [
|
|
13257
|
+
const [activeTab, setActiveTab] = (0, import_react75.useState)(() => {
|
|
13255
13258
|
const hasActiveChild = childrenArray.some(
|
|
13256
13259
|
(child) => (0, import_react75.isValidElement)(child) && (child.props.active || child.props.defaultActive) && !child.props.disabled
|
|
13257
13260
|
);
|
|
13258
13261
|
const initialActiveTab = hasActiveChild ? childrenArray.find(
|
|
13259
13262
|
(child) => (0, import_react75.isValidElement)(child) && (child.props.active || child.props.defaultActive) && !child.props.disabled
|
|
13260
13263
|
) : childrenArray.find((child) => (0, import_react75.isValidElement)(child) && !child.props.disabled);
|
|
13261
|
-
return (0, import_react75.isValidElement)(initialActiveTab) ? initialActiveTab.props.label : "";
|
|
13264
|
+
return (0, import_react75.isValidElement)(initialActiveTab) ? initialActiveTab.props.label ?? initialActiveTab.props.tabId : "";
|
|
13262
13265
|
});
|
|
13263
13266
|
const [innerFocusIndex, setInnerFocusIndex] = (0, import_react75.useState)(null);
|
|
13264
13267
|
const [activeIndicatorWidth, setActiveIndicatorWidth] = (0, import_react75.useState)(0);
|
|
@@ -13285,15 +13288,15 @@ var DxcTabs2 = ({
|
|
|
13285
13288
|
return {
|
|
13286
13289
|
iconPosition,
|
|
13287
13290
|
tabIndex,
|
|
13288
|
-
|
|
13291
|
+
focusedTab: (0, import_react75.isValidElement)(focusedChild) ? focusedChild.props.label ?? focusedChild.props.tabId : "",
|
|
13289
13292
|
isControlled: childrenArray.some((child) => (0, import_react75.isValidElement)(child) && typeof child.props.active !== "undefined"),
|
|
13290
|
-
|
|
13293
|
+
activeTab,
|
|
13291
13294
|
hasLabelAndIcon,
|
|
13292
|
-
|
|
13295
|
+
setActiveTab,
|
|
13293
13296
|
setActiveIndicatorWidth,
|
|
13294
13297
|
setActiveIndicatorLeft
|
|
13295
13298
|
};
|
|
13296
|
-
}, [iconPosition, tabIndex, innerFocusIndex,
|
|
13299
|
+
}, [iconPosition, tabIndex, innerFocusIndex, activeTab, childrenArray, hasLabelAndIcon]);
|
|
13297
13300
|
const scrollLeft = () => {
|
|
13298
13301
|
const scrollWidth = (refTabList?.current?.offsetHeight ?? 0) * 0.75;
|
|
13299
13302
|
let moveX = 0;
|
|
@@ -13326,21 +13329,23 @@ var DxcTabs2 = ({
|
|
|
13326
13329
|
setCountClick(moveX);
|
|
13327
13330
|
};
|
|
13328
13331
|
const handleOnKeyDown = (event) => {
|
|
13329
|
-
const
|
|
13332
|
+
const active = childrenArray.findIndex(
|
|
13333
|
+
(child) => child.props.label ?? child.props.tabId === activeTab
|
|
13334
|
+
);
|
|
13330
13335
|
switch (event.key) {
|
|
13331
13336
|
case "Left":
|
|
13332
13337
|
case "ArrowLeft":
|
|
13333
13338
|
event.preventDefault();
|
|
13334
|
-
setInnerFocusIndex(getPreviousTabIndex2(childrenArray, innerFocusIndex === null ?
|
|
13339
|
+
setInnerFocusIndex(getPreviousTabIndex2(childrenArray, innerFocusIndex === null ? active : innerFocusIndex));
|
|
13335
13340
|
break;
|
|
13336
13341
|
case "Right":
|
|
13337
13342
|
case "ArrowRight":
|
|
13338
13343
|
event.preventDefault();
|
|
13339
|
-
setInnerFocusIndex(getNextTabIndex2(childrenArray, innerFocusIndex === null ?
|
|
13344
|
+
setInnerFocusIndex(getNextTabIndex2(childrenArray, innerFocusIndex === null ? active : innerFocusIndex));
|
|
13340
13345
|
break;
|
|
13341
13346
|
case "Tab":
|
|
13342
|
-
if (
|
|
13343
|
-
setInnerFocusIndex(
|
|
13347
|
+
if (active !== innerFocusIndex) {
|
|
13348
|
+
setInnerFocusIndex(active);
|
|
13344
13349
|
}
|
|
13345
13350
|
break;
|
|
13346
13351
|
default:
|
|
@@ -13371,7 +13376,7 @@ var DxcTabs2 = ({
|
|
|
13371
13376
|
tabWidth: activeIndicatorWidth,
|
|
13372
13377
|
tabLeft: activeIndicatorLeft,
|
|
13373
13378
|
"aria-disabled": childrenArray.some(
|
|
13374
|
-
(child) => (0, import_react75.isValidElement)(child) &&
|
|
13379
|
+
(child) => (0, import_react75.isValidElement)(child) && activeTab === (child.props.label ?? child.props.tabId) && child.props.disabled
|
|
13375
13380
|
)
|
|
13376
13381
|
}
|
|
13377
13382
|
)
|
|
@@ -13391,7 +13396,7 @@ var DxcTabs2 = ({
|
|
|
13391
13396
|
] })
|
|
13392
13397
|
] }) }),
|
|
13393
13398
|
import_react75.Children.map(children, (child) => {
|
|
13394
|
-
if ((0, import_react75.isValidElement)(child) && child.props.label ===
|
|
13399
|
+
if ((0, import_react75.isValidElement)(child) && (child.props.label ?? child.props.tabId) === activeTab) {
|
|
13395
13400
|
return child.props.children;
|
|
13396
13401
|
}
|
|
13397
13402
|
return null;
|
package/dist/index.mjs
CHANGED
|
@@ -12422,6 +12422,7 @@ var DxcTab2 = forwardRef16(
|
|
|
12422
12422
|
icon,
|
|
12423
12423
|
label,
|
|
12424
12424
|
title,
|
|
12425
|
+
tabId = label,
|
|
12425
12426
|
disabled = false,
|
|
12426
12427
|
active,
|
|
12427
12428
|
notificationNumber = false,
|
|
@@ -12434,30 +12435,30 @@ var DxcTab2 = forwardRef16(
|
|
|
12434
12435
|
const {
|
|
12435
12436
|
iconPosition = "top",
|
|
12436
12437
|
tabIndex = 0,
|
|
12437
|
-
|
|
12438
|
+
focusedTab,
|
|
12438
12439
|
isControlled,
|
|
12439
|
-
|
|
12440
|
+
activeTab,
|
|
12440
12441
|
hasLabelAndIcon = false,
|
|
12441
|
-
|
|
12442
|
+
setActiveTab,
|
|
12442
12443
|
setActiveIndicatorWidth,
|
|
12443
12444
|
setActiveIndicatorLeft
|
|
12444
12445
|
} = useContext48(TabsContext_default) ?? {};
|
|
12445
12446
|
useEffect23(() => {
|
|
12446
|
-
if (
|
|
12447
|
+
if (focusedTab === tabId) {
|
|
12447
12448
|
tabRef?.current?.focus();
|
|
12448
12449
|
}
|
|
12449
|
-
}, [
|
|
12450
|
+
}, [focusedTab, tabId]);
|
|
12450
12451
|
useEffect23(() => {
|
|
12451
|
-
if (
|
|
12452
|
+
if (activeTab === tabId) {
|
|
12452
12453
|
setActiveIndicatorWidth?.(tabRef.current?.offsetWidth ?? 0);
|
|
12453
12454
|
setActiveIndicatorLeft?.(tabRef.current?.offsetLeft ?? 0);
|
|
12454
12455
|
}
|
|
12455
|
-
}, [
|
|
12456
|
+
}, [activeTab, tabId, setActiveIndicatorWidth, setActiveIndicatorLeft]);
|
|
12456
12457
|
useEffect23(() => {
|
|
12457
12458
|
if (active) {
|
|
12458
|
-
|
|
12459
|
+
setActiveTab?.(tabId ?? label ?? "");
|
|
12459
12460
|
}
|
|
12460
|
-
}, [active, label,
|
|
12461
|
+
}, [active, label, setActiveTab]);
|
|
12461
12462
|
const handleOnKeyDown = (event) => {
|
|
12462
12463
|
switch (event.key) {
|
|
12463
12464
|
case " ":
|
|
@@ -12474,9 +12475,10 @@ var DxcTab2 = forwardRef16(
|
|
|
12474
12475
|
{
|
|
12475
12476
|
role: "tab",
|
|
12476
12477
|
type: "button",
|
|
12477
|
-
tabIndex:
|
|
12478
|
+
tabIndex: activeTab === tabId && !disabled ? tabIndex : -1,
|
|
12478
12479
|
disabled,
|
|
12479
|
-
"aria-
|
|
12480
|
+
"aria-label": label ?? tabId ?? "tab",
|
|
12481
|
+
"aria-selected": activeTab === tabId,
|
|
12480
12482
|
hasLabelAndIcon,
|
|
12481
12483
|
iconPosition,
|
|
12482
12484
|
ref: (anchorRef) => {
|
|
@@ -12492,7 +12494,8 @@ var DxcTab2 = forwardRef16(
|
|
|
12492
12494
|
},
|
|
12493
12495
|
onClick: () => {
|
|
12494
12496
|
if (!isControlled) {
|
|
12495
|
-
|
|
12497
|
+
setActiveTab?.(tabId ?? "");
|
|
12498
|
+
console.log(tabId);
|
|
12496
12499
|
}
|
|
12497
12500
|
onClick();
|
|
12498
12501
|
},
|
|
@@ -12508,7 +12511,7 @@ var DxcTab2 = forwardRef16(
|
|
|
12508
12511
|
disabled,
|
|
12509
12512
|
children: [
|
|
12510
12513
|
icon && /* @__PURE__ */ jsx75(TabIconContainer2, { hasLabelAndIcon, iconPosition, children: typeof icon === "string" ? /* @__PURE__ */ jsx75(Icon_default, { icon }) : icon }),
|
|
12511
|
-
/* @__PURE__ */ jsx75(Label11, { disabled,
|
|
12514
|
+
label && /* @__PURE__ */ jsx75(Label11, { disabled, active: activeTab === tabId, label, children: label })
|
|
12512
12515
|
]
|
|
12513
12516
|
}
|
|
12514
12517
|
),
|
|
@@ -12600,7 +12603,7 @@ var MainLabelContainer = styled67.div`
|
|
|
12600
12603
|
`;
|
|
12601
12604
|
var Label11 = styled67.span`
|
|
12602
12605
|
display: inline;
|
|
12603
|
-
color: ${(props) => props.disabled ? props.theme.disabledFontColor : props.
|
|
12606
|
+
color: ${(props) => props.disabled ? props.theme.disabledFontColor : props.active ? props.theme.selectedFontColor : props.theme.unselectedFontColor};
|
|
12604
12607
|
font-family: ${(props) => props.theme.fontFamily};
|
|
12605
12608
|
font-size: ${(props) => props.theme.fontSize};
|
|
12606
12609
|
font-style: ${(props) => props.disabled ? props.theme.disabledFontStyle : props.theme.fontStyle};
|
|
@@ -13195,14 +13198,14 @@ var DxcTabs2 = ({
|
|
|
13195
13198
|
() => childrenArray.some((child) => isValidElement2(child) && child.props.icon && child.props.label),
|
|
13196
13199
|
[childrenArray]
|
|
13197
13200
|
);
|
|
13198
|
-
const [
|
|
13201
|
+
const [activeTab, setActiveTab] = useState33(() => {
|
|
13199
13202
|
const hasActiveChild = childrenArray.some(
|
|
13200
13203
|
(child) => isValidElement2(child) && (child.props.active || child.props.defaultActive) && !child.props.disabled
|
|
13201
13204
|
);
|
|
13202
13205
|
const initialActiveTab = hasActiveChild ? childrenArray.find(
|
|
13203
13206
|
(child) => isValidElement2(child) && (child.props.active || child.props.defaultActive) && !child.props.disabled
|
|
13204
13207
|
) : childrenArray.find((child) => isValidElement2(child) && !child.props.disabled);
|
|
13205
|
-
return isValidElement2(initialActiveTab) ? initialActiveTab.props.label : "";
|
|
13208
|
+
return isValidElement2(initialActiveTab) ? initialActiveTab.props.label ?? initialActiveTab.props.tabId : "";
|
|
13206
13209
|
});
|
|
13207
13210
|
const [innerFocusIndex, setInnerFocusIndex] = useState33(null);
|
|
13208
13211
|
const [activeIndicatorWidth, setActiveIndicatorWidth] = useState33(0);
|
|
@@ -13229,15 +13232,15 @@ var DxcTabs2 = ({
|
|
|
13229
13232
|
return {
|
|
13230
13233
|
iconPosition,
|
|
13231
13234
|
tabIndex,
|
|
13232
|
-
|
|
13235
|
+
focusedTab: isValidElement2(focusedChild) ? focusedChild.props.label ?? focusedChild.props.tabId : "",
|
|
13233
13236
|
isControlled: childrenArray.some((child) => isValidElement2(child) && typeof child.props.active !== "undefined"),
|
|
13234
|
-
|
|
13237
|
+
activeTab,
|
|
13235
13238
|
hasLabelAndIcon,
|
|
13236
|
-
|
|
13239
|
+
setActiveTab,
|
|
13237
13240
|
setActiveIndicatorWidth,
|
|
13238
13241
|
setActiveIndicatorLeft
|
|
13239
13242
|
};
|
|
13240
|
-
}, [iconPosition, tabIndex, innerFocusIndex,
|
|
13243
|
+
}, [iconPosition, tabIndex, innerFocusIndex, activeTab, childrenArray, hasLabelAndIcon]);
|
|
13241
13244
|
const scrollLeft = () => {
|
|
13242
13245
|
const scrollWidth = (refTabList?.current?.offsetHeight ?? 0) * 0.75;
|
|
13243
13246
|
let moveX = 0;
|
|
@@ -13270,21 +13273,23 @@ var DxcTabs2 = ({
|
|
|
13270
13273
|
setCountClick(moveX);
|
|
13271
13274
|
};
|
|
13272
13275
|
const handleOnKeyDown = (event) => {
|
|
13273
|
-
const
|
|
13276
|
+
const active = childrenArray.findIndex(
|
|
13277
|
+
(child) => child.props.label ?? child.props.tabId === activeTab
|
|
13278
|
+
);
|
|
13274
13279
|
switch (event.key) {
|
|
13275
13280
|
case "Left":
|
|
13276
13281
|
case "ArrowLeft":
|
|
13277
13282
|
event.preventDefault();
|
|
13278
|
-
setInnerFocusIndex(getPreviousTabIndex2(childrenArray, innerFocusIndex === null ?
|
|
13283
|
+
setInnerFocusIndex(getPreviousTabIndex2(childrenArray, innerFocusIndex === null ? active : innerFocusIndex));
|
|
13279
13284
|
break;
|
|
13280
13285
|
case "Right":
|
|
13281
13286
|
case "ArrowRight":
|
|
13282
13287
|
event.preventDefault();
|
|
13283
|
-
setInnerFocusIndex(getNextTabIndex2(childrenArray, innerFocusIndex === null ?
|
|
13288
|
+
setInnerFocusIndex(getNextTabIndex2(childrenArray, innerFocusIndex === null ? active : innerFocusIndex));
|
|
13284
13289
|
break;
|
|
13285
13290
|
case "Tab":
|
|
13286
|
-
if (
|
|
13287
|
-
setInnerFocusIndex(
|
|
13291
|
+
if (active !== innerFocusIndex) {
|
|
13292
|
+
setInnerFocusIndex(active);
|
|
13288
13293
|
}
|
|
13289
13294
|
break;
|
|
13290
13295
|
default:
|
|
@@ -13315,7 +13320,7 @@ var DxcTabs2 = ({
|
|
|
13315
13320
|
tabWidth: activeIndicatorWidth,
|
|
13316
13321
|
tabLeft: activeIndicatorLeft,
|
|
13317
13322
|
"aria-disabled": childrenArray.some(
|
|
13318
|
-
(child) => isValidElement2(child) &&
|
|
13323
|
+
(child) => isValidElement2(child) && activeTab === (child.props.label ?? child.props.tabId) && child.props.disabled
|
|
13319
13324
|
)
|
|
13320
13325
|
}
|
|
13321
13326
|
)
|
|
@@ -13335,7 +13340,7 @@ var DxcTabs2 = ({
|
|
|
13335
13340
|
] })
|
|
13336
13341
|
] }) }),
|
|
13337
13342
|
Children5.map(children, (child) => {
|
|
13338
|
-
if (isValidElement2(child) && child.props.label ===
|
|
13343
|
+
if (isValidElement2(child) && (child.props.label ?? child.props.tabId) === activeTab) {
|
|
13339
13344
|
return child.props.children;
|
|
13340
13345
|
}
|
|
13341
13346
|
return null;
|