@dxc-technology/halstack-react 15.0.1 → 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.mjs CHANGED
@@ -2191,6 +2191,7 @@ var AccordionLabel = styled4.span`
2191
2191
  overflow: hidden;
2192
2192
  text-overflow: ellipsis;
2193
2193
  white-space: nowrap;
2194
+ text-align: left;
2194
2195
  `;
2195
2196
  var SubLabel = styled4.span`
2196
2197
  height: 20px;
@@ -6102,13 +6103,15 @@ var renderExpandableTrigger = (row, rows, uniqueRowId, setRowsToRender) => /* @_
6102
6103
  return newRows;
6103
6104
  });
6104
6105
  }
6105
- }
6106
+ },
6107
+ disabled: !rows.some((row2) => uniqueRowId in row2)
6106
6108
  }
6107
6109
  );
6108
6110
  var renderHierarchyTrigger = (rows, triggerRow, uniqueRowId, columnKey, setRowsToRender) => /* @__PURE__ */ jsxs24(
6109
6111
  "button",
6110
6112
  {
6111
6113
  type: "button",
6114
+ disabled: !rows.some((row) => uniqueRowId in row),
6112
6115
  onClick: () => {
6113
6116
  let newRowsToRender = [...rows];
6114
6117
  if (!triggerRow.visibleChildren) {
@@ -6167,13 +6170,14 @@ var renderCheckbox = (rows, row, uniqueRowId, selectedRows, onSelectRows) => /*
6167
6170
  getParentSelectedState(rows, row.parentKey, uniqueRowId, selected, checked);
6168
6171
  }
6169
6172
  onSelectRows(selected);
6170
- }
6173
+ },
6174
+ disabled: !rows.some((row2) => uniqueRowId in row2)
6171
6175
  }
6172
6176
  );
6173
6177
  var renderHeaderCheckbox = (rows, uniqueRowId, selectedRows, colorsTheme, onSelectRows) => /* @__PURE__ */ jsx38(HalstackProvider, { advancedTheme: overwriteTheme(colorsTheme), children: /* @__PURE__ */ jsx38(
6174
6178
  Checkbox_default,
6175
6179
  {
6176
- checked: !rows.some((row) => !selectedRows.has(rowKeyGetter(row, uniqueRowId))),
6180
+ checked: rows.length > 0 && !rows.some((row) => !selectedRows.has(rowKeyGetter(row, uniqueRowId))),
6177
6181
  onChange: (checked) => {
6178
6182
  const updatedSelection = new Set(selectedRows);
6179
6183
  if (checked) {
@@ -6192,7 +6196,8 @@ var renderHeaderCheckbox = (rows, uniqueRowId, selectedRows, colorsTheme, onSele
6192
6196
  });
6193
6197
  }
6194
6198
  onSelectRows(updatedSelection);
6195
- }
6199
+ },
6200
+ disabled: rows.length === 0 || !rows.some((row) => uniqueRowId in row)
6196
6201
  }
6197
6202
  ) });
6198
6203
  var rowKeyGetter = (row, uniqueRowId) => {
@@ -6246,7 +6251,7 @@ var sortHierarchyRows = (rows, sortColumns, sortFunctions, uniqueRowId) => {
6246
6251
  true
6247
6252
  );
6248
6253
  while (sortedChildren.length) {
6249
- if (uniqueRowId) {
6254
+ if (uniqueRowId && sortedChildren.some((row) => uniqueRowId in row)) {
6250
6255
  sortedChildren = sortedChildren.reduce(
6251
6256
  (remainingChilds, child) => {
6252
6257
  const parentIndex = parentsSorted.findIndex(
@@ -6299,6 +6304,9 @@ var getChildrenSelection = (rowList, uniqueRowId, selectedRows, checked) => {
6299
6304
  });
6300
6305
  };
6301
6306
  var getParentSelectedState = (rowList, parentKeyValue, uniqueRowId, selectedRows, checkedStateToMatch) => {
6307
+ if (!rowList.some((row) => uniqueRowId in row)) {
6308
+ return;
6309
+ }
6302
6310
  const parentRow = rowFinderBasedOnId(rowList, uniqueRowId, parentKeyValue);
6303
6311
  if (!parentRow) {
6304
6312
  return;
@@ -7631,6 +7639,142 @@ var Table_default = DxcTable;
7631
7639
 
7632
7640
  // src/data-grid/DataGrid.tsx
7633
7641
  import { jsx as jsx44, jsxs as jsxs30 } from "react/jsx-runtime";
7642
+ var ActionContainer = styled37.div`
7643
+ display: flex;
7644
+ height: 100%;
7645
+ align-items: center;
7646
+ justify-content: center;
7647
+ font-size: 14px;
7648
+ width: 100%;
7649
+ `;
7650
+ var HierarchyContainer = styled37.div`
7651
+ padding-left: ${(props) => `calc(${props.theme.dataPaddingLeft} * ${props.level})`};
7652
+ button {
7653
+ display: grid;
7654
+ grid-template-columns: auto 1fr;
7655
+ align-items: center;
7656
+ gap: 0.5rem;
7657
+ padding: 0px;
7658
+ border: 0px;
7659
+ width: 100%;
7660
+ height: ${(props) => props.theme.dataRowHeight}px;
7661
+ background: transparent;
7662
+ text-align: left;
7663
+ font-size: ${(props) => props.theme.dataFontSize};
7664
+ font-family: inherit;
7665
+ color: inherit;
7666
+ cursor: pointer;
7667
+ }
7668
+ `;
7669
+ var DataGridContainer = styled37.div`
7670
+ width: 100%;
7671
+ height: ${(props) => props.paginatorRendered ? `calc(100% - 50px)` : `100%`};
7672
+ .rdg {
7673
+ border-radius: 4px;
7674
+ height: 100%;
7675
+ border: 0px;
7676
+ &::-webkit-scrollbar {
7677
+ width: 8px;
7678
+ height: 8px;
7679
+ }
7680
+ &::-webkit-scrollbar-thumb {
7681
+ background-color: ${(props) => props.theme.scrollBarThumbColor};
7682
+ border-radius: 6px;
7683
+ }
7684
+ &::-webkit-scrollbar-track {
7685
+ background-color: ${(props) => props.theme.scrollBarTrackColor};
7686
+ border-radius: 6px;
7687
+ }
7688
+ }
7689
+ .rdg-cell:has(> #action) {
7690
+ padding: 0px;
7691
+ }
7692
+ .rdg-cell {
7693
+ display: grid;
7694
+ align-items: center;
7695
+ width: 100%;
7696
+ padding: 0px ${(props) => props.theme.dataPaddingRight} 0 ${(props) => props.theme.dataPaddingLeft};
7697
+ font-family: ${(props) => props.theme.dataFontFamily};
7698
+ font-size: ${(props) => props.theme.dataFontSize};
7699
+ font-style: ${(props) => props.theme.dataFontStyle};
7700
+ font-weight: ${(props) => props.theme.dataFontWeight};
7701
+ color: ${(props) => props.theme.dataFontColor};
7702
+ text-transform: ${(props) => props.theme.dataFontTextTransform};
7703
+ line-height: ${(props) => props.theme.dataTextLineHeight};
7704
+ border-bottom: ${(props) => `${props.theme.rowSeparatorThickness} ${props.theme.rowSeparatorStyle} ${props.theme.rowSeparatorColor}`};
7705
+ border-right: ${(props) => `${props.theme.rowSeparatorThickness} ${props.theme.rowSeparatorStyle} ${props.theme.rowSeparatorColor}`};
7706
+ background-color: ${(props) => props.theme.dataBackgroundColor};
7707
+ outline-color: ${(props) => props.theme.focusColor} !important;
7708
+ .rdg-text-editor:focus {
7709
+ border-color: transparent;
7710
+ background-color: transparent;
7711
+ color: ${(props) => props.theme.dataFontColor};
7712
+ }
7713
+ }
7714
+ .rdg-header-row {
7715
+ border-top-left-radius: ${(props) => props.theme.headerBorderRadius};
7716
+ border-top-right-radius: ${(props) => props.theme.headerBorderRadius};
7717
+ .rdg-cell {
7718
+ font-family: ${(props) => props.theme.headerFontFamily};
7719
+ font-size: ${(props) => props.theme.headerFontSize};
7720
+ font-style: ${(props) => props.theme.headerFontStyle};
7721
+ font-weight: ${(props) => props.theme.headerFontWeight};
7722
+ color: ${(props) => props.theme.headerFontColor};
7723
+ text-transform: ${(props) => props.theme.headerFontTextTransform};
7724
+ padding: 0px ${(props) => props.theme.headerPaddingRight} 0 ${(props) => props.theme.headerPaddingLeft};
7725
+ line-height: ${(props) => props.theme.headerTextLineHeight};
7726
+ background-color: ${(props) => props.theme.headerBackgroundColor};
7727
+ .sortIconContainer {
7728
+ margin-left: 0.5rem;
7729
+ display: flex;
7730
+ height: 100%;
7731
+ align-items: center;
7732
+ }
7733
+ }
7734
+ }
7735
+ .rdg-row {
7736
+ .rdg-cell:last-child {
7737
+ border-right: 0px;
7738
+ }
7739
+ }
7740
+ .rdg-summary-row {
7741
+ background-color: #fafafa;
7742
+ .rdg-cell {
7743
+ border: 0px;
7744
+ font-weight: 600;
7745
+ }
7746
+ }
7747
+ .ellipsis-cell {
7748
+ text-overflow: ellipsis;
7749
+ overflow: hidden;
7750
+ white-space: nowrap;
7751
+ width: 100%;
7752
+ height: 100%;
7753
+ display: flex;
7754
+ align-items: center;
7755
+ }
7756
+ .align-left {
7757
+ text-align: left;
7758
+ justify-content: flex-start;
7759
+ }
7760
+ .align-center {
7761
+ text-align: center;
7762
+ justify-content: center;
7763
+ }
7764
+ .align-right {
7765
+ text-align: right;
7766
+ justify-content: flex-end;
7767
+ }
7768
+ .header-align-left {
7769
+ text-align: left;
7770
+ }
7771
+ .header-align-center {
7772
+ text-align: center;
7773
+ }
7774
+ .header-align-right {
7775
+ text-align: right;
7776
+ }
7777
+ `;
7634
7778
  var DxcDataGrid = ({
7635
7779
  columns,
7636
7780
  rows,
@@ -7648,11 +7792,12 @@ var DxcDataGrid = ({
7648
7792
  itemsPerPageFunction,
7649
7793
  onSort,
7650
7794
  onPageChange,
7651
- totalItems
7795
+ totalItems,
7796
+ defaultPage = 1
7652
7797
  }) => {
7653
7798
  const [rowsToRender, setRowsToRender] = useState17(rows);
7654
7799
  const colorsTheme = useContext24(HalstackContext);
7655
- const [page, changePage] = useState17(1);
7800
+ const [page, changePage] = useState17(defaultPage);
7656
7801
  const goToPage = (newPage) => {
7657
7802
  if (onPageChange) {
7658
7803
  onPageChange(newPage);
@@ -7734,7 +7879,21 @@ var DxcDataGrid = ({
7734
7879
  setColumnsOrder(Array.from({ length: columnsToRender.length }, (_, index) => index));
7735
7880
  }, [columnsToRender.length]);
7736
7881
  useEffect8(() => {
7737
- setRowsToRender(rows);
7882
+ const finalRows = [...rows];
7883
+ if (expandable) {
7884
+ rows.forEach((row, index) => {
7885
+ if (row.contentIsExpanded && !rows.some((row2) => row2[uniqueRowId] === `${rowKeyGetter(row2, uniqueRowId)}_expanded`)) {
7886
+ addRow(finalRows, index + 1, {
7887
+ isExpandedChildContent: row.contentIsExpanded,
7888
+ [uniqueRowId]: `${rowKeyGetter(row, uniqueRowId)}_expanded`,
7889
+ expandedChildContent: row.expandedContent,
7890
+ triggerRowKey: rowKeyGetter(row, uniqueRowId),
7891
+ expandedContentHeight: row.expandedContentHeight
7892
+ });
7893
+ }
7894
+ });
7895
+ }
7896
+ setRowsToRender(finalRows);
7738
7897
  }, [rows]);
7739
7898
  const reorderedColumns = useMemo10(
7740
7899
  () => (
@@ -7771,23 +7930,28 @@ var DxcDataGrid = ({
7771
7930
  const sortedRows = useMemo10(() => {
7772
7931
  const sortFunctions = getCustomSortFn(columns);
7773
7932
  if (!onSort) {
7774
- if (expandable && sortColumns.length > 0) {
7775
- const innerSortedRows = sortRows(
7776
- rowsToRender.filter((row) => !row.isExpandedChildContent),
7777
- sortColumns,
7778
- sortFunctions
7779
- );
7780
- rowsToRender.filter((row) => row.isExpandedChildContent).map(
7781
- (expandedRow) => addRow(
7782
- innerSortedRows,
7783
- innerSortedRows.findIndex((trigger) => rowKeyGetter(trigger, uniqueRowId) === expandedRow.triggerRowKey) + 1,
7784
- expandedRow
7785
- )
7786
- );
7787
- return innerSortedRows;
7788
- }
7789
- if (!expandable && sortColumns.length > 0 && uniqueRowId) {
7790
- return sortHierarchyRows(rowsToRender, sortColumns, sortFunctions, uniqueRowId);
7933
+ if (sortColumns.length > 0 && uniqueRowId) {
7934
+ if (expandable) {
7935
+ const innerSortedRows = sortRows(
7936
+ rowsToRender.filter((row) => !row.isExpandedChildContent),
7937
+ sortColumns,
7938
+ sortFunctions
7939
+ );
7940
+ if (innerSortedRows.some((row) => uniqueRowId in row)) {
7941
+ rowsToRender.filter((row) => row.isExpandedChildContent).map(
7942
+ (expandedRow) => addRow(
7943
+ innerSortedRows,
7944
+ innerSortedRows.findIndex(
7945
+ (trigger) => rowKeyGetter(trigger, uniqueRowId) === expandedRow.triggerRowKey
7946
+ ) + 1,
7947
+ expandedRow
7948
+ )
7949
+ );
7950
+ return innerSortedRows;
7951
+ }
7952
+ } else {
7953
+ return sortHierarchyRows(rowsToRender, sortColumns, sortFunctions, uniqueRowId);
7954
+ }
7791
7955
  }
7792
7956
  }
7793
7957
  return rowsToRender;
@@ -7803,7 +7967,7 @@ var DxcDataGrid = ({
7803
7967
  }
7804
7968
  return !showPaginator || onPageChange ? sortedRows : getPaginatedNodes(sortedRows, uniqueRowId, minItemsPerPageIndex, maxItemsPerPageIndex + 1);
7805
7969
  }, [sortedRows, minItemsPerPageIndex, maxItemsPerPageIndex]);
7806
- return /* @__PURE__ */ jsx44(ThemeProvider17, { theme: colorsTheme.dataGrid, children: /* @__PURE__ */ jsxs30(DataGridContainer, { children: [
7970
+ return /* @__PURE__ */ jsx44(ThemeProvider17, { theme: colorsTheme.dataGrid, children: /* @__PURE__ */ jsxs30(DataGridContainer, { paginatorRendered: showPaginator && (totalItems ?? rows.length) > itemsPerPage, children: [
7807
7971
  /* @__PURE__ */ jsx44(
7808
7972
  DataGrid,
7809
7973
  {
@@ -7823,7 +7987,7 @@ var DxcDataGrid = ({
7823
7987
  className: "fill-grid"
7824
7988
  }
7825
7989
  ),
7826
- showPaginator && /* @__PURE__ */ jsx44(
7990
+ showPaginator && (totalItems ?? rows.length) > itemsPerPage && /* @__PURE__ */ jsx44(
7827
7991
  Paginator_default,
7828
7992
  {
7829
7993
  totalItems: totalItems ?? rows.length,
@@ -7837,140 +8001,6 @@ var DxcDataGrid = ({
7837
8001
  )
7838
8002
  ] }) });
7839
8003
  };
7840
- var ActionContainer = styled37.div`
7841
- display: flex;
7842
- height: 100%;
7843
- align-items: center;
7844
- justify-content: center;
7845
- font-size: 14px;
7846
- width: 100%;
7847
- `;
7848
- var HierarchyContainer = styled37.div`
7849
- padding-left: ${(props) => `calc(${props.theme.dataPaddingLeft} * ${props.level})`};
7850
- button {
7851
- display: grid;
7852
- grid-template-columns: auto 1fr;
7853
- align-items: center;
7854
- gap: 0.5rem;
7855
- padding: 0px;
7856
- border: 0px;
7857
- width: 100%;
7858
- height: ${(props) => props.theme.dataRowHeight}px;
7859
- background: transparent;
7860
- text-align: left;
7861
- font-size: ${(props) => props.theme.dataFontSize};
7862
- font-family: inherit;
7863
- color: inherit;
7864
- cursor: pointer;
7865
- }
7866
- `;
7867
- var DataGridContainer = styled37.div`
7868
- width: 100%;
7869
- height: 100%;
7870
- .rdg {
7871
- border-radius: 4px;
7872
- height: 100%;
7873
- border: 0px;
7874
- &::-webkit-scrollbar {
7875
- width: 8px;
7876
- height: 8px;
7877
- }
7878
- &::-webkit-scrollbar-thumb {
7879
- background-color: ${(props) => props.theme.scrollBarThumbColor};
7880
- border-radius: 6px;
7881
- }
7882
- &::-webkit-scrollbar-track {
7883
- background-color: ${(props) => props.theme.scrollBarTrackColor};
7884
- border-radius: 6px;
7885
- }
7886
- }
7887
- .rdg-cell:has(> #action) {
7888
- padding: 0px;
7889
- }
7890
- .rdg-cell {
7891
- display: grid;
7892
- align-items: center;
7893
- width: 100%;
7894
- padding: 0px ${(props) => props.theme.dataPaddingRight} 0 ${(props) => props.theme.dataPaddingLeft};
7895
- font-family: ${(props) => props.theme.dataFontFamily};
7896
- font-size: ${(props) => props.theme.dataFontSize};
7897
- font-style: ${(props) => props.theme.dataFontStyle};
7898
- font-weight: ${(props) => props.theme.dataFontWeight};
7899
- color: ${(props) => props.theme.dataFontColor};
7900
- text-transform: ${(props) => props.theme.dataFontTextTransform};
7901
- line-height: ${(props) => props.theme.dataTextLineHeight};
7902
- border-bottom: ${(props) => `${props.theme.rowSeparatorThickness} ${props.theme.rowSeparatorStyle} ${props.theme.rowSeparatorColor}`};
7903
- border-right: ${(props) => `${props.theme.rowSeparatorThickness} ${props.theme.rowSeparatorStyle} ${props.theme.rowSeparatorColor}`};
7904
- background-color: ${(props) => props.theme.dataBackgroundColor};
7905
- outline-color: ${(props) => props.theme.focusColor} !important;
7906
- .rdg-text-editor:focus {
7907
- border-color: transparent;
7908
- }
7909
- }
7910
- .rdg-header-row {
7911
- border-top-left-radius: ${(props) => props.theme.headerBorderRadius};
7912
- border-top-right-radius: ${(props) => props.theme.headerBorderRadius};
7913
- .rdg-cell {
7914
- font-family: ${(props) => props.theme.headerFontFamily};
7915
- font-size: ${(props) => props.theme.headerFontSize};
7916
- font-style: ${(props) => props.theme.headerFontStyle};
7917
- font-weight: ${(props) => props.theme.headerFontWeight};
7918
- color: ${(props) => props.theme.headerFontColor};
7919
- text-transform: ${(props) => props.theme.headerFontTextTransform};
7920
- padding: 0px ${(props) => props.theme.headerPaddingRight} 0 ${(props) => props.theme.headerPaddingLeft};
7921
- line-height: ${(props) => props.theme.headerTextLineHeight};
7922
- background-color: ${(props) => props.theme.headerBackgroundColor};
7923
- .sortIconContainer {
7924
- margin-left: 0.5rem;
7925
- display: flex;
7926
- height: 100%;
7927
- align-items: center;
7928
- }
7929
- }
7930
- }
7931
- .rdg-row {
7932
- .rdg-cell:last-child {
7933
- border-right: 0px;
7934
- }
7935
- }
7936
- .rdg-summary-row {
7937
- background-color: #fafafa;
7938
- .rdg-cell {
7939
- border: 0px;
7940
- font-weight: 600;
7941
- }
7942
- }
7943
- .ellipsis-cell {
7944
- text-overflow: ellipsis;
7945
- overflow: hidden;
7946
- white-space: nowrap;
7947
- width: 100%;
7948
- height: 100%;
7949
- display: flex;
7950
- align-items: center;
7951
- }
7952
- .align-left {
7953
- text-align: left;
7954
- justify-content: flex-start;
7955
- }
7956
- .align-center {
7957
- text-align: center;
7958
- justify-content: center;
7959
- }
7960
- .align-right {
7961
- text-align: right;
7962
- justify-content: flex-end;
7963
- }
7964
- .header-align-left {
7965
- text-align: left;
7966
- }
7967
- .header-align-center {
7968
- text-align: center;
7969
- }
7970
- .header-align-right {
7971
- text-align: right;
7972
- }
7973
- `;
7974
8004
  DxcDataGrid.ActionsCell = DxcActionsCell;
7975
8005
  var DataGrid_default = DxcDataGrid;
7976
8006
 
@@ -12392,6 +12422,7 @@ var DxcTab2 = forwardRef16(
12392
12422
  icon,
12393
12423
  label,
12394
12424
  title,
12425
+ tabId = label,
12395
12426
  disabled = false,
12396
12427
  active,
12397
12428
  notificationNumber = false,
@@ -12404,30 +12435,30 @@ var DxcTab2 = forwardRef16(
12404
12435
  const {
12405
12436
  iconPosition = "top",
12406
12437
  tabIndex = 0,
12407
- focusedLabel,
12438
+ focusedTab,
12408
12439
  isControlled,
12409
- activeLabel,
12440
+ activeTab,
12410
12441
  hasLabelAndIcon = false,
12411
- setActiveLabel,
12442
+ setActiveTab,
12412
12443
  setActiveIndicatorWidth,
12413
12444
  setActiveIndicatorLeft
12414
12445
  } = useContext48(TabsContext_default) ?? {};
12415
12446
  useEffect23(() => {
12416
- if (focusedLabel === label) {
12447
+ if (focusedTab === tabId) {
12417
12448
  tabRef?.current?.focus();
12418
12449
  }
12419
- }, [focusedLabel, label]);
12450
+ }, [focusedTab, tabId]);
12420
12451
  useEffect23(() => {
12421
- if (activeLabel === label) {
12452
+ if (activeTab === tabId) {
12422
12453
  setActiveIndicatorWidth?.(tabRef.current?.offsetWidth ?? 0);
12423
12454
  setActiveIndicatorLeft?.(tabRef.current?.offsetLeft ?? 0);
12424
12455
  }
12425
- }, [activeLabel, label, setActiveIndicatorWidth, setActiveIndicatorLeft]);
12456
+ }, [activeTab, tabId, setActiveIndicatorWidth, setActiveIndicatorLeft]);
12426
12457
  useEffect23(() => {
12427
12458
  if (active) {
12428
- setActiveLabel?.(label);
12459
+ setActiveTab?.(tabId ?? label ?? "");
12429
12460
  }
12430
- }, [active, label, setActiveLabel]);
12461
+ }, [active, label, setActiveTab]);
12431
12462
  const handleOnKeyDown = (event) => {
12432
12463
  switch (event.key) {
12433
12464
  case " ":
@@ -12444,9 +12475,10 @@ var DxcTab2 = forwardRef16(
12444
12475
  {
12445
12476
  role: "tab",
12446
12477
  type: "button",
12447
- tabIndex: activeLabel === label && !disabled ? tabIndex : -1,
12478
+ tabIndex: activeTab === tabId && !disabled ? tabIndex : -1,
12448
12479
  disabled,
12449
- "aria-selected": activeLabel === label,
12480
+ "aria-label": label ?? tabId ?? "tab",
12481
+ "aria-selected": activeTab === tabId,
12450
12482
  hasLabelAndIcon,
12451
12483
  iconPosition,
12452
12484
  ref: (anchorRef) => {
@@ -12462,7 +12494,8 @@ var DxcTab2 = forwardRef16(
12462
12494
  },
12463
12495
  onClick: () => {
12464
12496
  if (!isControlled) {
12465
- setActiveLabel?.(label);
12497
+ setActiveTab?.(tabId ?? "");
12498
+ console.log(tabId);
12466
12499
  }
12467
12500
  onClick();
12468
12501
  },
@@ -12478,7 +12511,7 @@ var DxcTab2 = forwardRef16(
12478
12511
  disabled,
12479
12512
  children: [
12480
12513
  icon && /* @__PURE__ */ jsx75(TabIconContainer2, { hasLabelAndIcon, iconPosition, children: typeof icon === "string" ? /* @__PURE__ */ jsx75(Icon_default, { icon }) : icon }),
12481
- /* @__PURE__ */ jsx75(Label11, { disabled, activeLabel, label, children: label })
12514
+ label && /* @__PURE__ */ jsx75(Label11, { disabled, active: activeTab === tabId, label, children: label })
12482
12515
  ]
12483
12516
  }
12484
12517
  ),
@@ -12570,7 +12603,7 @@ var MainLabelContainer = styled67.div`
12570
12603
  `;
12571
12604
  var Label11 = styled67.span`
12572
12605
  display: inline;
12573
- color: ${(props) => props.disabled ? props.theme.disabledFontColor : props.activeLabel === props.label ? props.theme.selectedFontColor : props.theme.unselectedFontColor};
12606
+ color: ${(props) => props.disabled ? props.theme.disabledFontColor : props.active ? props.theme.selectedFontColor : props.theme.unselectedFontColor};
12574
12607
  font-family: ${(props) => props.theme.fontFamily};
12575
12608
  font-size: ${(props) => props.theme.fontSize};
12576
12609
  font-style: ${(props) => props.disabled ? props.theme.disabledFontStyle : props.theme.fontStyle};
@@ -13165,14 +13198,14 @@ var DxcTabs2 = ({
13165
13198
  () => childrenArray.some((child) => isValidElement2(child) && child.props.icon && child.props.label),
13166
13199
  [childrenArray]
13167
13200
  );
13168
- const [activeTabLabel, setActiveTabLabel] = useState33(() => {
13201
+ const [activeTab, setActiveTab] = useState33(() => {
13169
13202
  const hasActiveChild = childrenArray.some(
13170
13203
  (child) => isValidElement2(child) && (child.props.active || child.props.defaultActive) && !child.props.disabled
13171
13204
  );
13172
13205
  const initialActiveTab = hasActiveChild ? childrenArray.find(
13173
13206
  (child) => isValidElement2(child) && (child.props.active || child.props.defaultActive) && !child.props.disabled
13174
13207
  ) : childrenArray.find((child) => isValidElement2(child) && !child.props.disabled);
13175
- return isValidElement2(initialActiveTab) ? initialActiveTab.props.label : "";
13208
+ return isValidElement2(initialActiveTab) ? initialActiveTab.props.label ?? initialActiveTab.props.tabId : "";
13176
13209
  });
13177
13210
  const [innerFocusIndex, setInnerFocusIndex] = useState33(null);
13178
13211
  const [activeIndicatorWidth, setActiveIndicatorWidth] = useState33(0);
@@ -13199,15 +13232,15 @@ var DxcTabs2 = ({
13199
13232
  return {
13200
13233
  iconPosition,
13201
13234
  tabIndex,
13202
- focusedLabel: isValidElement2(focusedChild) ? focusedChild.props.label : "",
13235
+ focusedTab: isValidElement2(focusedChild) ? focusedChild.props.label ?? focusedChild.props.tabId : "",
13203
13236
  isControlled: childrenArray.some((child) => isValidElement2(child) && typeof child.props.active !== "undefined"),
13204
- activeLabel: activeTabLabel,
13237
+ activeTab,
13205
13238
  hasLabelAndIcon,
13206
- setActiveLabel: setActiveTabLabel,
13239
+ setActiveTab,
13207
13240
  setActiveIndicatorWidth,
13208
13241
  setActiveIndicatorLeft
13209
13242
  };
13210
- }, [iconPosition, tabIndex, innerFocusIndex, activeTabLabel, childrenArray, hasLabelAndIcon]);
13243
+ }, [iconPosition, tabIndex, innerFocusIndex, activeTab, childrenArray, hasLabelAndIcon]);
13211
13244
  const scrollLeft = () => {
13212
13245
  const scrollWidth = (refTabList?.current?.offsetHeight ?? 0) * 0.75;
13213
13246
  let moveX = 0;
@@ -13240,21 +13273,23 @@ var DxcTabs2 = ({
13240
13273
  setCountClick(moveX);
13241
13274
  };
13242
13275
  const handleOnKeyDown = (event) => {
13243
- const activeTab = childrenArray.findIndex((child) => child.props.label === activeTabLabel);
13276
+ const active = childrenArray.findIndex(
13277
+ (child) => child.props.label ?? child.props.tabId === activeTab
13278
+ );
13244
13279
  switch (event.key) {
13245
13280
  case "Left":
13246
13281
  case "ArrowLeft":
13247
13282
  event.preventDefault();
13248
- setInnerFocusIndex(getPreviousTabIndex2(childrenArray, innerFocusIndex === null ? activeTab : innerFocusIndex));
13283
+ setInnerFocusIndex(getPreviousTabIndex2(childrenArray, innerFocusIndex === null ? active : innerFocusIndex));
13249
13284
  break;
13250
13285
  case "Right":
13251
13286
  case "ArrowRight":
13252
13287
  event.preventDefault();
13253
- setInnerFocusIndex(getNextTabIndex2(childrenArray, innerFocusIndex === null ? activeTab : innerFocusIndex));
13288
+ setInnerFocusIndex(getNextTabIndex2(childrenArray, innerFocusIndex === null ? active : innerFocusIndex));
13254
13289
  break;
13255
13290
  case "Tab":
13256
- if (activeTab !== innerFocusIndex) {
13257
- setInnerFocusIndex(activeTab);
13291
+ if (active !== innerFocusIndex) {
13292
+ setInnerFocusIndex(active);
13258
13293
  }
13259
13294
  break;
13260
13295
  default:
@@ -13285,7 +13320,7 @@ var DxcTabs2 = ({
13285
13320
  tabWidth: activeIndicatorWidth,
13286
13321
  tabLeft: activeIndicatorLeft,
13287
13322
  "aria-disabled": childrenArray.some(
13288
- (child) => isValidElement2(child) && activeTabLabel === child.props.label && child.props.disabled
13323
+ (child) => isValidElement2(child) && activeTab === (child.props.label ?? child.props.tabId) && child.props.disabled
13289
13324
  )
13290
13325
  }
13291
13326
  )
@@ -13305,7 +13340,7 @@ var DxcTabs2 = ({
13305
13340
  ] })
13306
13341
  ] }) }),
13307
13342
  Children5.map(children, (child) => {
13308
- if (isValidElement2(child) && child.props.label === activeTabLabel) {
13343
+ if (isValidElement2(child) && (child.props.label ?? child.props.tabId) === activeTab) {
13309
13344
  return child.props.children;
13310
13345
  }
13311
13346
  return null;
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@dxc-technology/halstack-react",
3
- "type": "commonjs",
4
- "version": "15.0.1",
3
+ "version": "15.1.1",
5
4
  "repository": {
6
5
  "type": "git",
7
6
  "url": "git+https://github.com/dxc-technology/halstack-react.git"