@dxc-technology/halstack-react 15.0.1 → 15.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1263,6 +1263,7 @@ type HierarchyGridRow = GridRow & {
1263
1263
  type ExpandableGridRow = GridRow & {
1264
1264
  expandedContent?: ReactNode;
1265
1265
  expandedContentHeight?: number;
1266
+ contentIsExpanded?: boolean;
1266
1267
  };
1267
1268
  type ExpandableRows = {
1268
1269
  rows: ExpandableGridRow[];
@@ -1339,6 +1340,10 @@ type PaginatedProps$1 = {
1339
1340
  * Function called whenever the current page is changed.
1340
1341
  */
1341
1342
  onPageChange?: (_page: number) => void;
1343
+ /**
1344
+ * Default page in which the datagrid is rendered
1345
+ */
1346
+ defaultPage?: number;
1342
1347
  };
1343
1348
  type NonPaginatedProps$1 = {
1344
1349
  /**
@@ -1370,6 +1375,10 @@ type NonPaginatedProps$1 = {
1370
1375
  * Function called whenever the current page is changed.
1371
1376
  */
1372
1377
  onPageChange?: never;
1378
+ /**
1379
+ * Default page in which the datagrid is rendered
1380
+ */
1381
+ defaultPage?: never;
1373
1382
  };
1374
1383
  type CommonProps$6 = {
1375
1384
  columns: GridColumn[];
@@ -1397,7 +1406,7 @@ type BasicGridProps = {
1397
1406
  type Props$t = CommonProps$6 & (PaginatedProps$1 | NonPaginatedProps$1) & ((BasicGridProps & SelectableGridProps) | (ExpandableRows & SelectableGridProps) | (HierarchyRows & SelectableGridProps));
1398
1407
 
1399
1408
  declare const DxcDataGrid: {
1400
- ({ columns, rows, selectable, expandable, onSelectRows, selectedRows, uniqueRowId, summaryRow, onGridRowsChange, showPaginator, showGoToPage, itemsPerPage, itemsPerPageOptions, itemsPerPageFunction, onSort, onPageChange, totalItems, }: Props$t): JSX.Element;
1409
+ ({ columns, rows, selectable, expandable, onSelectRows, selectedRows, uniqueRowId, summaryRow, onGridRowsChange, showPaginator, showGoToPage, itemsPerPage, itemsPerPageOptions, itemsPerPageFunction, onSort, onPageChange, totalItems, defaultPage, }: Props$t): JSX.Element;
1401
1410
  ActionsCell: ({ actions }: ActionCellsPropsType) => JSX.Element;
1402
1411
  };
1403
1412
 
package/dist/index.d.ts CHANGED
@@ -1263,6 +1263,7 @@ type HierarchyGridRow = GridRow & {
1263
1263
  type ExpandableGridRow = GridRow & {
1264
1264
  expandedContent?: ReactNode;
1265
1265
  expandedContentHeight?: number;
1266
+ contentIsExpanded?: boolean;
1266
1267
  };
1267
1268
  type ExpandableRows = {
1268
1269
  rows: ExpandableGridRow[];
@@ -1339,6 +1340,10 @@ type PaginatedProps$1 = {
1339
1340
  * Function called whenever the current page is changed.
1340
1341
  */
1341
1342
  onPageChange?: (_page: number) => void;
1343
+ /**
1344
+ * Default page in which the datagrid is rendered
1345
+ */
1346
+ defaultPage?: number;
1342
1347
  };
1343
1348
  type NonPaginatedProps$1 = {
1344
1349
  /**
@@ -1370,6 +1375,10 @@ type NonPaginatedProps$1 = {
1370
1375
  * Function called whenever the current page is changed.
1371
1376
  */
1372
1377
  onPageChange?: never;
1378
+ /**
1379
+ * Default page in which the datagrid is rendered
1380
+ */
1381
+ defaultPage?: never;
1373
1382
  };
1374
1383
  type CommonProps$6 = {
1375
1384
  columns: GridColumn[];
@@ -1397,7 +1406,7 @@ type BasicGridProps = {
1397
1406
  type Props$t = CommonProps$6 & (PaginatedProps$1 | NonPaginatedProps$1) & ((BasicGridProps & SelectableGridProps) | (ExpandableRows & SelectableGridProps) | (HierarchyRows & SelectableGridProps));
1398
1407
 
1399
1408
  declare const DxcDataGrid: {
1400
- ({ columns, rows, selectable, expandable, onSelectRows, selectedRows, uniqueRowId, summaryRow, onGridRowsChange, showPaginator, showGoToPage, itemsPerPage, itemsPerPageOptions, itemsPerPageFunction, onSort, onPageChange, totalItems, }: Props$t): JSX.Element;
1409
+ ({ columns, rows, selectable, expandable, onSelectRows, selectedRows, uniqueRowId, summaryRow, onGridRowsChange, showPaginator, showGoToPage, itemsPerPage, itemsPerPageOptions, itemsPerPageFunction, onSort, onPageChange, totalItems, defaultPage, }: Props$t): JSX.Element;
1401
1410
  ActionsCell: ({ actions }: ActionCellsPropsType) => JSX.Element;
1402
1411
  };
1403
1412
 
package/dist/index.js CHANGED
@@ -2279,6 +2279,7 @@ var AccordionLabel = import_styled_components4.default.span`
2279
2279
  overflow: hidden;
2280
2280
  text-overflow: ellipsis;
2281
2281
  white-space: nowrap;
2282
+ text-align: left;
2282
2283
  `;
2283
2284
  var SubLabel = import_styled_components4.default.span`
2284
2285
  height: 20px;
@@ -6190,13 +6191,15 @@ var renderExpandableTrigger = (row, rows, uniqueRowId, setRowsToRender) => /* @_
6190
6191
  return newRows;
6191
6192
  });
6192
6193
  }
6193
- }
6194
+ },
6195
+ disabled: !rows.some((row2) => uniqueRowId in row2)
6194
6196
  }
6195
6197
  );
6196
6198
  var renderHierarchyTrigger = (rows, triggerRow, uniqueRowId, columnKey, setRowsToRender) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
6197
6199
  "button",
6198
6200
  {
6199
6201
  type: "button",
6202
+ disabled: !rows.some((row) => uniqueRowId in row),
6200
6203
  onClick: () => {
6201
6204
  let newRowsToRender = [...rows];
6202
6205
  if (!triggerRow.visibleChildren) {
@@ -6255,13 +6258,14 @@ var renderCheckbox = (rows, row, uniqueRowId, selectedRows, onSelectRows) => /*
6255
6258
  getParentSelectedState(rows, row.parentKey, uniqueRowId, selected, checked);
6256
6259
  }
6257
6260
  onSelectRows(selected);
6258
- }
6261
+ },
6262
+ disabled: !rows.some((row2) => uniqueRowId in row2)
6259
6263
  }
6260
6264
  );
6261
6265
  var renderHeaderCheckbox = (rows, uniqueRowId, selectedRows, colorsTheme, onSelectRows) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(HalstackProvider, { advancedTheme: overwriteTheme(colorsTheme), children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
6262
6266
  Checkbox_default,
6263
6267
  {
6264
- checked: !rows.some((row) => !selectedRows.has(rowKeyGetter(row, uniqueRowId))),
6268
+ checked: rows.length > 0 && !rows.some((row) => !selectedRows.has(rowKeyGetter(row, uniqueRowId))),
6265
6269
  onChange: (checked) => {
6266
6270
  const updatedSelection = new Set(selectedRows);
6267
6271
  if (checked) {
@@ -6280,7 +6284,8 @@ var renderHeaderCheckbox = (rows, uniqueRowId, selectedRows, colorsTheme, onSele
6280
6284
  });
6281
6285
  }
6282
6286
  onSelectRows(updatedSelection);
6283
- }
6287
+ },
6288
+ disabled: rows.length === 0 || !rows.some((row) => uniqueRowId in row)
6284
6289
  }
6285
6290
  ) });
6286
6291
  var rowKeyGetter = (row, uniqueRowId) => {
@@ -6334,7 +6339,7 @@ var sortHierarchyRows = (rows, sortColumns, sortFunctions, uniqueRowId) => {
6334
6339
  true
6335
6340
  );
6336
6341
  while (sortedChildren.length) {
6337
- if (uniqueRowId) {
6342
+ if (uniqueRowId && sortedChildren.some((row) => uniqueRowId in row)) {
6338
6343
  sortedChildren = sortedChildren.reduce(
6339
6344
  (remainingChilds, child) => {
6340
6345
  const parentIndex = parentsSorted.findIndex(
@@ -6387,6 +6392,9 @@ var getChildrenSelection = (rowList, uniqueRowId, selectedRows, checked) => {
6387
6392
  });
6388
6393
  };
6389
6394
  var getParentSelectedState = (rowList, parentKeyValue, uniqueRowId, selectedRows, checkedStateToMatch) => {
6395
+ if (!rowList.some((row) => uniqueRowId in row)) {
6396
+ return;
6397
+ }
6390
6398
  const parentRow = rowFinderBasedOnId(rowList, uniqueRowId, parentKeyValue);
6391
6399
  if (!parentRow) {
6392
6400
  return;
@@ -7711,6 +7719,142 @@ var Table_default = DxcTable;
7711
7719
 
7712
7720
  // src/data-grid/DataGrid.tsx
7713
7721
  var import_jsx_runtime44 = require("react/jsx-runtime");
7722
+ var ActionContainer = import_styled_components37.default.div`
7723
+ display: flex;
7724
+ height: 100%;
7725
+ align-items: center;
7726
+ justify-content: center;
7727
+ font-size: 14px;
7728
+ width: 100%;
7729
+ `;
7730
+ var HierarchyContainer = import_styled_components37.default.div`
7731
+ padding-left: ${(props) => `calc(${props.theme.dataPaddingLeft} * ${props.level})`};
7732
+ button {
7733
+ display: grid;
7734
+ grid-template-columns: auto 1fr;
7735
+ align-items: center;
7736
+ gap: 0.5rem;
7737
+ padding: 0px;
7738
+ border: 0px;
7739
+ width: 100%;
7740
+ height: ${(props) => props.theme.dataRowHeight}px;
7741
+ background: transparent;
7742
+ text-align: left;
7743
+ font-size: ${(props) => props.theme.dataFontSize};
7744
+ font-family: inherit;
7745
+ color: inherit;
7746
+ cursor: pointer;
7747
+ }
7748
+ `;
7749
+ var DataGridContainer = import_styled_components37.default.div`
7750
+ width: 100%;
7751
+ height: ${(props) => props.paginatorRendered ? `calc(100% - 50px)` : `100%`};
7752
+ .rdg {
7753
+ border-radius: 4px;
7754
+ height: 100%;
7755
+ border: 0px;
7756
+ &::-webkit-scrollbar {
7757
+ width: 8px;
7758
+ height: 8px;
7759
+ }
7760
+ &::-webkit-scrollbar-thumb {
7761
+ background-color: ${(props) => props.theme.scrollBarThumbColor};
7762
+ border-radius: 6px;
7763
+ }
7764
+ &::-webkit-scrollbar-track {
7765
+ background-color: ${(props) => props.theme.scrollBarTrackColor};
7766
+ border-radius: 6px;
7767
+ }
7768
+ }
7769
+ .rdg-cell:has(> #action) {
7770
+ padding: 0px;
7771
+ }
7772
+ .rdg-cell {
7773
+ display: grid;
7774
+ align-items: center;
7775
+ width: 100%;
7776
+ padding: 0px ${(props) => props.theme.dataPaddingRight} 0 ${(props) => props.theme.dataPaddingLeft};
7777
+ font-family: ${(props) => props.theme.dataFontFamily};
7778
+ font-size: ${(props) => props.theme.dataFontSize};
7779
+ font-style: ${(props) => props.theme.dataFontStyle};
7780
+ font-weight: ${(props) => props.theme.dataFontWeight};
7781
+ color: ${(props) => props.theme.dataFontColor};
7782
+ text-transform: ${(props) => props.theme.dataFontTextTransform};
7783
+ line-height: ${(props) => props.theme.dataTextLineHeight};
7784
+ border-bottom: ${(props) => `${props.theme.rowSeparatorThickness} ${props.theme.rowSeparatorStyle} ${props.theme.rowSeparatorColor}`};
7785
+ border-right: ${(props) => `${props.theme.rowSeparatorThickness} ${props.theme.rowSeparatorStyle} ${props.theme.rowSeparatorColor}`};
7786
+ background-color: ${(props) => props.theme.dataBackgroundColor};
7787
+ outline-color: ${(props) => props.theme.focusColor} !important;
7788
+ .rdg-text-editor:focus {
7789
+ border-color: transparent;
7790
+ background-color: transparent;
7791
+ color: ${(props) => props.theme.dataFontColor};
7792
+ }
7793
+ }
7794
+ .rdg-header-row {
7795
+ border-top-left-radius: ${(props) => props.theme.headerBorderRadius};
7796
+ border-top-right-radius: ${(props) => props.theme.headerBorderRadius};
7797
+ .rdg-cell {
7798
+ font-family: ${(props) => props.theme.headerFontFamily};
7799
+ font-size: ${(props) => props.theme.headerFontSize};
7800
+ font-style: ${(props) => props.theme.headerFontStyle};
7801
+ font-weight: ${(props) => props.theme.headerFontWeight};
7802
+ color: ${(props) => props.theme.headerFontColor};
7803
+ text-transform: ${(props) => props.theme.headerFontTextTransform};
7804
+ padding: 0px ${(props) => props.theme.headerPaddingRight} 0 ${(props) => props.theme.headerPaddingLeft};
7805
+ line-height: ${(props) => props.theme.headerTextLineHeight};
7806
+ background-color: ${(props) => props.theme.headerBackgroundColor};
7807
+ .sortIconContainer {
7808
+ margin-left: 0.5rem;
7809
+ display: flex;
7810
+ height: 100%;
7811
+ align-items: center;
7812
+ }
7813
+ }
7814
+ }
7815
+ .rdg-row {
7816
+ .rdg-cell:last-child {
7817
+ border-right: 0px;
7818
+ }
7819
+ }
7820
+ .rdg-summary-row {
7821
+ background-color: #fafafa;
7822
+ .rdg-cell {
7823
+ border: 0px;
7824
+ font-weight: 600;
7825
+ }
7826
+ }
7827
+ .ellipsis-cell {
7828
+ text-overflow: ellipsis;
7829
+ overflow: hidden;
7830
+ white-space: nowrap;
7831
+ width: 100%;
7832
+ height: 100%;
7833
+ display: flex;
7834
+ align-items: center;
7835
+ }
7836
+ .align-left {
7837
+ text-align: left;
7838
+ justify-content: flex-start;
7839
+ }
7840
+ .align-center {
7841
+ text-align: center;
7842
+ justify-content: center;
7843
+ }
7844
+ .align-right {
7845
+ text-align: right;
7846
+ justify-content: flex-end;
7847
+ }
7848
+ .header-align-left {
7849
+ text-align: left;
7850
+ }
7851
+ .header-align-center {
7852
+ text-align: center;
7853
+ }
7854
+ .header-align-right {
7855
+ text-align: right;
7856
+ }
7857
+ `;
7714
7858
  var DxcDataGrid = ({
7715
7859
  columns,
7716
7860
  rows,
@@ -7728,11 +7872,12 @@ var DxcDataGrid = ({
7728
7872
  itemsPerPageFunction,
7729
7873
  onSort,
7730
7874
  onPageChange,
7731
- totalItems
7875
+ totalItems,
7876
+ defaultPage = 1
7732
7877
  }) => {
7733
7878
  const [rowsToRender, setRowsToRender] = (0, import_react42.useState)(rows);
7734
7879
  const colorsTheme = (0, import_react42.useContext)(HalstackContext);
7735
- const [page, changePage] = (0, import_react42.useState)(1);
7880
+ const [page, changePage] = (0, import_react42.useState)(defaultPage);
7736
7881
  const goToPage = (newPage) => {
7737
7882
  if (onPageChange) {
7738
7883
  onPageChange(newPage);
@@ -7814,7 +7959,21 @@ var DxcDataGrid = ({
7814
7959
  setColumnsOrder(Array.from({ length: columnsToRender.length }, (_, index) => index));
7815
7960
  }, [columnsToRender.length]);
7816
7961
  (0, import_react42.useEffect)(() => {
7817
- setRowsToRender(rows);
7962
+ const finalRows = [...rows];
7963
+ if (expandable) {
7964
+ rows.forEach((row, index) => {
7965
+ if (row.contentIsExpanded && !rows.some((row2) => row2[uniqueRowId] === `${rowKeyGetter(row2, uniqueRowId)}_expanded`)) {
7966
+ addRow(finalRows, index + 1, {
7967
+ isExpandedChildContent: row.contentIsExpanded,
7968
+ [uniqueRowId]: `${rowKeyGetter(row, uniqueRowId)}_expanded`,
7969
+ expandedChildContent: row.expandedContent,
7970
+ triggerRowKey: rowKeyGetter(row, uniqueRowId),
7971
+ expandedContentHeight: row.expandedContentHeight
7972
+ });
7973
+ }
7974
+ });
7975
+ }
7976
+ setRowsToRender(finalRows);
7818
7977
  }, [rows]);
7819
7978
  const reorderedColumns = (0, import_react42.useMemo)(
7820
7979
  () => (
@@ -7851,23 +8010,28 @@ var DxcDataGrid = ({
7851
8010
  const sortedRows = (0, import_react42.useMemo)(() => {
7852
8011
  const sortFunctions = getCustomSortFn(columns);
7853
8012
  if (!onSort) {
7854
- if (expandable && sortColumns.length > 0) {
7855
- const innerSortedRows = sortRows(
7856
- rowsToRender.filter((row) => !row.isExpandedChildContent),
7857
- sortColumns,
7858
- sortFunctions
7859
- );
7860
- rowsToRender.filter((row) => row.isExpandedChildContent).map(
7861
- (expandedRow) => addRow(
7862
- innerSortedRows,
7863
- innerSortedRows.findIndex((trigger) => rowKeyGetter(trigger, uniqueRowId) === expandedRow.triggerRowKey) + 1,
7864
- expandedRow
7865
- )
7866
- );
7867
- return innerSortedRows;
7868
- }
7869
- if (!expandable && sortColumns.length > 0 && uniqueRowId) {
7870
- return sortHierarchyRows(rowsToRender, sortColumns, sortFunctions, uniqueRowId);
8013
+ if (sortColumns.length > 0 && uniqueRowId) {
8014
+ if (expandable) {
8015
+ const innerSortedRows = sortRows(
8016
+ rowsToRender.filter((row) => !row.isExpandedChildContent),
8017
+ sortColumns,
8018
+ sortFunctions
8019
+ );
8020
+ if (innerSortedRows.some((row) => uniqueRowId in row)) {
8021
+ rowsToRender.filter((row) => row.isExpandedChildContent).map(
8022
+ (expandedRow) => addRow(
8023
+ innerSortedRows,
8024
+ innerSortedRows.findIndex(
8025
+ (trigger) => rowKeyGetter(trigger, uniqueRowId) === expandedRow.triggerRowKey
8026
+ ) + 1,
8027
+ expandedRow
8028
+ )
8029
+ );
8030
+ return innerSortedRows;
8031
+ }
8032
+ } else {
8033
+ return sortHierarchyRows(rowsToRender, sortColumns, sortFunctions, uniqueRowId);
8034
+ }
7871
8035
  }
7872
8036
  }
7873
8037
  return rowsToRender;
@@ -7883,7 +8047,7 @@ var DxcDataGrid = ({
7883
8047
  }
7884
8048
  return !showPaginator || onPageChange ? sortedRows : getPaginatedNodes(sortedRows, uniqueRowId, minItemsPerPageIndex, maxItemsPerPageIndex + 1);
7885
8049
  }, [sortedRows, minItemsPerPageIndex, maxItemsPerPageIndex]);
7886
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_styled_components37.ThemeProvider, { theme: colorsTheme.dataGrid, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(DataGridContainer, { children: [
8050
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_styled_components37.ThemeProvider, { theme: colorsTheme.dataGrid, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(DataGridContainer, { paginatorRendered: showPaginator && (totalItems ?? rows.length) > itemsPerPage, children: [
7887
8051
  /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
7888
8052
  import_react_data_grid2.default,
7889
8053
  {
@@ -7903,7 +8067,7 @@ var DxcDataGrid = ({
7903
8067
  className: "fill-grid"
7904
8068
  }
7905
8069
  ),
7906
- showPaginator && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
8070
+ showPaginator && (totalItems ?? rows.length) > itemsPerPage && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
7907
8071
  Paginator_default,
7908
8072
  {
7909
8073
  totalItems: totalItems ?? rows.length,
@@ -7917,140 +8081,6 @@ var DxcDataGrid = ({
7917
8081
  )
7918
8082
  ] }) });
7919
8083
  };
7920
- var ActionContainer = import_styled_components37.default.div`
7921
- display: flex;
7922
- height: 100%;
7923
- align-items: center;
7924
- justify-content: center;
7925
- font-size: 14px;
7926
- width: 100%;
7927
- `;
7928
- var HierarchyContainer = import_styled_components37.default.div`
7929
- padding-left: ${(props) => `calc(${props.theme.dataPaddingLeft} * ${props.level})`};
7930
- button {
7931
- display: grid;
7932
- grid-template-columns: auto 1fr;
7933
- align-items: center;
7934
- gap: 0.5rem;
7935
- padding: 0px;
7936
- border: 0px;
7937
- width: 100%;
7938
- height: ${(props) => props.theme.dataRowHeight}px;
7939
- background: transparent;
7940
- text-align: left;
7941
- font-size: ${(props) => props.theme.dataFontSize};
7942
- font-family: inherit;
7943
- color: inherit;
7944
- cursor: pointer;
7945
- }
7946
- `;
7947
- var DataGridContainer = import_styled_components37.default.div`
7948
- width: 100%;
7949
- height: 100%;
7950
- .rdg {
7951
- border-radius: 4px;
7952
- height: 100%;
7953
- border: 0px;
7954
- &::-webkit-scrollbar {
7955
- width: 8px;
7956
- height: 8px;
7957
- }
7958
- &::-webkit-scrollbar-thumb {
7959
- background-color: ${(props) => props.theme.scrollBarThumbColor};
7960
- border-radius: 6px;
7961
- }
7962
- &::-webkit-scrollbar-track {
7963
- background-color: ${(props) => props.theme.scrollBarTrackColor};
7964
- border-radius: 6px;
7965
- }
7966
- }
7967
- .rdg-cell:has(> #action) {
7968
- padding: 0px;
7969
- }
7970
- .rdg-cell {
7971
- display: grid;
7972
- align-items: center;
7973
- width: 100%;
7974
- padding: 0px ${(props) => props.theme.dataPaddingRight} 0 ${(props) => props.theme.dataPaddingLeft};
7975
- font-family: ${(props) => props.theme.dataFontFamily};
7976
- font-size: ${(props) => props.theme.dataFontSize};
7977
- font-style: ${(props) => props.theme.dataFontStyle};
7978
- font-weight: ${(props) => props.theme.dataFontWeight};
7979
- color: ${(props) => props.theme.dataFontColor};
7980
- text-transform: ${(props) => props.theme.dataFontTextTransform};
7981
- line-height: ${(props) => props.theme.dataTextLineHeight};
7982
- border-bottom: ${(props) => `${props.theme.rowSeparatorThickness} ${props.theme.rowSeparatorStyle} ${props.theme.rowSeparatorColor}`};
7983
- border-right: ${(props) => `${props.theme.rowSeparatorThickness} ${props.theme.rowSeparatorStyle} ${props.theme.rowSeparatorColor}`};
7984
- background-color: ${(props) => props.theme.dataBackgroundColor};
7985
- outline-color: ${(props) => props.theme.focusColor} !important;
7986
- .rdg-text-editor:focus {
7987
- border-color: transparent;
7988
- }
7989
- }
7990
- .rdg-header-row {
7991
- border-top-left-radius: ${(props) => props.theme.headerBorderRadius};
7992
- border-top-right-radius: ${(props) => props.theme.headerBorderRadius};
7993
- .rdg-cell {
7994
- font-family: ${(props) => props.theme.headerFontFamily};
7995
- font-size: ${(props) => props.theme.headerFontSize};
7996
- font-style: ${(props) => props.theme.headerFontStyle};
7997
- font-weight: ${(props) => props.theme.headerFontWeight};
7998
- color: ${(props) => props.theme.headerFontColor};
7999
- text-transform: ${(props) => props.theme.headerFontTextTransform};
8000
- padding: 0px ${(props) => props.theme.headerPaddingRight} 0 ${(props) => props.theme.headerPaddingLeft};
8001
- line-height: ${(props) => props.theme.headerTextLineHeight};
8002
- background-color: ${(props) => props.theme.headerBackgroundColor};
8003
- .sortIconContainer {
8004
- margin-left: 0.5rem;
8005
- display: flex;
8006
- height: 100%;
8007
- align-items: center;
8008
- }
8009
- }
8010
- }
8011
- .rdg-row {
8012
- .rdg-cell:last-child {
8013
- border-right: 0px;
8014
- }
8015
- }
8016
- .rdg-summary-row {
8017
- background-color: #fafafa;
8018
- .rdg-cell {
8019
- border: 0px;
8020
- font-weight: 600;
8021
- }
8022
- }
8023
- .ellipsis-cell {
8024
- text-overflow: ellipsis;
8025
- overflow: hidden;
8026
- white-space: nowrap;
8027
- width: 100%;
8028
- height: 100%;
8029
- display: flex;
8030
- align-items: center;
8031
- }
8032
- .align-left {
8033
- text-align: left;
8034
- justify-content: flex-start;
8035
- }
8036
- .align-center {
8037
- text-align: center;
8038
- justify-content: center;
8039
- }
8040
- .align-right {
8041
- text-align: right;
8042
- justify-content: flex-end;
8043
- }
8044
- .header-align-left {
8045
- text-align: left;
8046
- }
8047
- .header-align-center {
8048
- text-align: center;
8049
- }
8050
- .header-align-right {
8051
- text-align: right;
8052
- }
8053
- `;
8054
8084
  DxcDataGrid.ActionsCell = DxcActionsCell;
8055
8085
  var DataGrid_default = DxcDataGrid;
8056
8086
 
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
 
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.0",
5
4
  "repository": {
6
5
  "type": "git",
7
6
  "url": "git+https://github.com/dxc-technology/halstack-react.git"