@ceed/cds 1.31.1 → 1.31.2-next.2

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.cjs CHANGED
@@ -3600,12 +3600,13 @@ var BodyCell = (props) => {
3600
3600
  [props.editMode, isCellEditable, params]
3601
3601
  );
3602
3602
  const propsComponentProps = "componentProps" in props ? props.componentProps : null;
3603
+ const hasComponentProps = "componentProps" in props;
3603
3604
  const componentProps = (0, import_react24.useMemo)(
3604
3605
  () => ({
3605
- ..."componentProps" in props && (typeof propsComponentProps === "function" ? propsComponentProps(params) : propsComponentProps || {}),
3606
+ ...hasComponentProps && (typeof propsComponentProps === "function" ? propsComponentProps(params) : propsComponentProps || {}),
3606
3607
  size: "sm"
3607
3608
  }),
3608
- [props, propsComponentProps, params]
3609
+ [hasComponentProps, propsComponentProps, params]
3609
3610
  );
3610
3611
  const editModeComponentProps = (0, import_react24.useMemo)(
3611
3612
  () => ({
@@ -3669,9 +3670,11 @@ var BodyCell = (props) => {
3669
3670
  }),
3670
3671
  [params, row, field, value, componentProps, type, onCellEditStop, onCellEditStart]
3671
3672
  );
3673
+ const MemoizedRenderEditCell = (0, import_react24.useMemo)(() => renderEditCell ? (0, import_react24.memo)(renderEditCell) : null, [renderEditCell]);
3674
+ const MemoizedRenderCell = (0, import_react24.useMemo)(() => renderCell ? (0, import_react24.memo)(renderCell) : null, [renderCell]);
3672
3675
  const EditModeComponent = (0, import_react24.useMemo)(() => {
3673
- if (renderEditCell) {
3674
- return (0, import_react24.createElement)((0, import_react24.memo)(renderEditCell), params);
3676
+ if (MemoizedRenderEditCell) {
3677
+ return (0, import_react24.createElement)(MemoizedRenderEditCell, params);
3675
3678
  }
3676
3679
  return {
3677
3680
  date: /* @__PURE__ */ import_react24.default.createElement(DatePicker_default, { value, ...editModeComponentProps }),
@@ -3702,11 +3705,11 @@ var BodyCell = (props) => {
3702
3705
  }
3703
3706
  )
3704
3707
  }[type || "text"];
3705
- }, [value, editModeComponentProps, type, renderEditCell, params]);
3708
+ }, [value, editModeComponentProps, type, MemoizedRenderEditCell, params]);
3706
3709
  const linkComponentFromProps = props.component;
3707
3710
  const ReadModeComponent = (0, import_react24.useMemo)(() => {
3708
- if (renderCell) {
3709
- return (0, import_react24.createElement)((0, import_react24.memo)(renderCell), params);
3711
+ if (MemoizedRenderCell) {
3712
+ return (0, import_react24.createElement)(MemoizedRenderCell, params);
3710
3713
  }
3711
3714
  const innerText = value;
3712
3715
  const typedComponent = {
@@ -3716,7 +3719,7 @@ var BodyCell = (props) => {
3716
3719
  })
3717
3720
  }[type || "text"];
3718
3721
  return typedComponent || innerText;
3719
- }, [value, renderCell, params, type, componentProps, linkComponentFromProps]);
3722
+ }, [value, MemoizedRenderCell, params, type, componentProps, linkComponentFromProps]);
3720
3723
  const getActions = props.getActions;
3721
3724
  const CellComponent = (0, import_react24.useMemo)(() => {
3722
3725
  if (type === "actions") {
@@ -3795,8 +3798,9 @@ var StyledTableRow2 = (0, import_joy32.styled)("tr", {
3795
3798
  var VirtualizedTableRow = (0, import_react24.memo)(StyledTableRow2, (prevProps, nextProps) => {
3796
3799
  return prevProps.striped === nextProps.striped && prevProps.style?.height === nextProps.style?.height && prevProps.style?.transform === nextProps.style?.transform && // @ts-ignore
3797
3800
  prevProps["data-row-id"] === nextProps["data-row-id"] && // @ts-ignore
3798
- prevProps["data-index"] === nextProps["data-index"] && prevProps.tabIndex === nextProps.tabIndex && prevProps["aria-checked"] === nextProps["aria-checked"] && // Include children check to handle isCellEditable changes
3799
- prevProps.children === nextProps.children;
3801
+ prevProps["data-index"] === nextProps["data-index"] && prevProps.tabIndex === nextProps.tabIndex && prevProps["aria-checked"] === nextProps["aria-checked"] && // Track column structure changes (e.g. isCellEditable toggled, columns added/removed)
3802
+ // @ts-ignore
3803
+ prevProps["data-columns-key"] === nextProps["data-columns-key"];
3800
3804
  });
3801
3805
 
3802
3806
  // src/components/DataTable/hooks.ts
@@ -4503,6 +4507,15 @@ Pagination.displayName = "Pagination";
4503
4507
  var Pagination_default = Pagination;
4504
4508
 
4505
4509
  // src/components/DataTable/DataTable.tsx
4510
+ var _columnsVersionCache = /* @__PURE__ */ new WeakMap();
4511
+ var _columnsVersionCounter = 0;
4512
+ function getColumnsVersion(columns) {
4513
+ if (!_columnsVersionCache.has(columns)) {
4514
+ _columnsVersionCache.set(columns, ++_columnsVersionCounter);
4515
+ }
4516
+ return _columnsVersionCache.get(columns);
4517
+ }
4518
+ var EMPTY_CHECKBOX_PROPS = {};
4506
4519
  function Component(props, apiRef) {
4507
4520
  const {
4508
4521
  rows,
@@ -4550,7 +4563,7 @@ function Component(props, apiRef) {
4550
4563
  noRowsOverlay: NoRowsOverlay = DefaultNoRowsOverlay
4551
4564
  } = {},
4552
4565
  slotProps: {
4553
- checkbox: checkboxProps = {},
4566
+ checkbox: checkboxProps = EMPTY_CHECKBOX_PROPS,
4554
4567
  toolbar: toolbarProps,
4555
4568
  background: backgroundProps = {},
4556
4569
  noRowsOverlay: noRowsOverlayProps = {}
@@ -4598,6 +4611,28 @@ function Component(props, apiRef) {
4598
4611
  overscan: 10
4599
4612
  });
4600
4613
  const paginationModel = (0, import_react28.useMemo)(() => ({ page, pageSize }), [page, pageSize]);
4614
+ const columnsKey = getColumnsVersion(columns);
4615
+ const headerCheckboxElement = (0, import_react28.useMemo)(
4616
+ () => /* @__PURE__ */ import_react28.default.createElement(
4617
+ RenderCheckbox,
4618
+ {
4619
+ onChange: onAllCheckboxChange,
4620
+ checked: isAllSelected,
4621
+ indeterminate: (selectionModel || []).length > 0 && !isAllSelected,
4622
+ disabled: dataInPage.length > 0 && !selectableRowCount,
4623
+ ...checkboxProps
4624
+ }
4625
+ ),
4626
+ [
4627
+ RenderCheckbox,
4628
+ onAllCheckboxChange,
4629
+ isAllSelected,
4630
+ selectionModel,
4631
+ selectableRowCount,
4632
+ dataInPage.length,
4633
+ checkboxProps
4634
+ ]
4635
+ );
4601
4636
  const totalSize = virtualizer.getTotalSize();
4602
4637
  const virtualizedItems = virtualizer.getVirtualItems();
4603
4638
  const showNoRowsOverlay = !loading && rowCount === 0;
@@ -4802,16 +4837,7 @@ function Component(props, apiRef) {
4802
4837
  verticalAlign: "middle"
4803
4838
  }
4804
4839
  },
4805
- /* @__PURE__ */ import_react28.default.createElement(
4806
- RenderCheckbox,
4807
- {
4808
- onChange: onAllCheckboxChange,
4809
- checked: isAllSelected,
4810
- indeterminate: (selectionModel || []).length > 0 && !isAllSelected,
4811
- disabled: dataInPage.length > 0 && !selectableRowCount,
4812
- ...checkboxProps
4813
- }
4814
- )
4840
+ headerCheckboxElement
4815
4841
  ), level > 0 && Array.from({ length: levelGroups[0]?.startIndex || 0 }).map((_2, i) => /* @__PURE__ */ import_react28.default.createElement("th", { key: `empty-${level}-${i}` })), levelGroups.filter((g) => g.colspan > 0).map((group, groupIndex) => {
4816
4842
  const nextGroup = levelGroups[groupIndex + 1];
4817
4843
  const emptyCells = nextGroup ? nextGroup.startIndex - (group.startIndex + group.colspan) : columns.length - (group.startIndex + group.colspan);
@@ -4838,16 +4864,7 @@ function Component(props, apiRef) {
4838
4864
  textAlign: "center"
4839
4865
  }
4840
4866
  },
4841
- /* @__PURE__ */ import_react28.default.createElement(
4842
- RenderCheckbox,
4843
- {
4844
- onChange: onAllCheckboxChange,
4845
- checked: isAllSelected,
4846
- indeterminate: (selectionModel || []).length > 0 && !isAllSelected,
4847
- disabled: dataInPage.length > 0 && !selectableRowCount,
4848
- ...checkboxProps
4849
- }
4850
- )
4867
+ headerCheckboxElement
4851
4868
  ), columns.map((c, i) => (
4852
4869
  // @ts-ignore
4853
4870
  /* @__PURE__ */ import_react28.default.createElement(
@@ -4918,6 +4935,7 @@ function Component(props, apiRef) {
4918
4935
  key: virtualizedRow.key,
4919
4936
  "data-row-id": rowId,
4920
4937
  "data-index": rowIndex,
4938
+ "data-columns-key": columnsKey,
4921
4939
  "aria-rowindex": rowIndex + 1,
4922
4940
  role: checkboxSelection && !disableSelectionOnClick ? "checkbox" : void 0,
4923
4941
  tabIndex: focusedRowId === rowId ? 0 : -1,
package/dist/index.js CHANGED
@@ -3483,12 +3483,13 @@ var BodyCell = (props) => {
3483
3483
  [props.editMode, isCellEditable, params]
3484
3484
  );
3485
3485
  const propsComponentProps = "componentProps" in props ? props.componentProps : null;
3486
+ const hasComponentProps = "componentProps" in props;
3486
3487
  const componentProps = useMemo8(
3487
3488
  () => ({
3488
- ..."componentProps" in props && (typeof propsComponentProps === "function" ? propsComponentProps(params) : propsComponentProps || {}),
3489
+ ...hasComponentProps && (typeof propsComponentProps === "function" ? propsComponentProps(params) : propsComponentProps || {}),
3489
3490
  size: "sm"
3490
3491
  }),
3491
- [props, propsComponentProps, params]
3492
+ [hasComponentProps, propsComponentProps, params]
3492
3493
  );
3493
3494
  const editModeComponentProps = useMemo8(
3494
3495
  () => ({
@@ -3552,9 +3553,11 @@ var BodyCell = (props) => {
3552
3553
  }),
3553
3554
  [params, row, field, value, componentProps, type, onCellEditStop, onCellEditStart]
3554
3555
  );
3556
+ const MemoizedRenderEditCell = useMemo8(() => renderEditCell ? memo(renderEditCell) : null, [renderEditCell]);
3557
+ const MemoizedRenderCell = useMemo8(() => renderCell ? memo(renderCell) : null, [renderCell]);
3555
3558
  const EditModeComponent = useMemo8(() => {
3556
- if (renderEditCell) {
3557
- return createElement(memo(renderEditCell), params);
3559
+ if (MemoizedRenderEditCell) {
3560
+ return createElement(MemoizedRenderEditCell, params);
3558
3561
  }
3559
3562
  return {
3560
3563
  date: /* @__PURE__ */ React22.createElement(DatePicker_default, { value, ...editModeComponentProps }),
@@ -3585,11 +3588,11 @@ var BodyCell = (props) => {
3585
3588
  }
3586
3589
  )
3587
3590
  }[type || "text"];
3588
- }, [value, editModeComponentProps, type, renderEditCell, params]);
3591
+ }, [value, editModeComponentProps, type, MemoizedRenderEditCell, params]);
3589
3592
  const linkComponentFromProps = props.component;
3590
3593
  const ReadModeComponent = useMemo8(() => {
3591
- if (renderCell) {
3592
- return createElement(memo(renderCell), params);
3594
+ if (MemoizedRenderCell) {
3595
+ return createElement(MemoizedRenderCell, params);
3593
3596
  }
3594
3597
  const innerText = value;
3595
3598
  const typedComponent = {
@@ -3599,7 +3602,7 @@ var BodyCell = (props) => {
3599
3602
  })
3600
3603
  }[type || "text"];
3601
3604
  return typedComponent || innerText;
3602
- }, [value, renderCell, params, type, componentProps, linkComponentFromProps]);
3605
+ }, [value, MemoizedRenderCell, params, type, componentProps, linkComponentFromProps]);
3603
3606
  const getActions = props.getActions;
3604
3607
  const CellComponent = useMemo8(() => {
3605
3608
  if (type === "actions") {
@@ -3678,8 +3681,9 @@ var StyledTableRow2 = styled12("tr", {
3678
3681
  var VirtualizedTableRow = memo(StyledTableRow2, (prevProps, nextProps) => {
3679
3682
  return prevProps.striped === nextProps.striped && prevProps.style?.height === nextProps.style?.height && prevProps.style?.transform === nextProps.style?.transform && // @ts-ignore
3680
3683
  prevProps["data-row-id"] === nextProps["data-row-id"] && // @ts-ignore
3681
- prevProps["data-index"] === nextProps["data-index"] && prevProps.tabIndex === nextProps.tabIndex && prevProps["aria-checked"] === nextProps["aria-checked"] && // Include children check to handle isCellEditable changes
3682
- prevProps.children === nextProps.children;
3684
+ prevProps["data-index"] === nextProps["data-index"] && prevProps.tabIndex === nextProps.tabIndex && prevProps["aria-checked"] === nextProps["aria-checked"] && // Track column structure changes (e.g. isCellEditable toggled, columns added/removed)
3685
+ // @ts-ignore
3686
+ prevProps["data-columns-key"] === nextProps["data-columns-key"];
3683
3687
  });
3684
3688
 
3685
3689
  // src/components/DataTable/hooks.ts
@@ -4386,6 +4390,15 @@ Pagination.displayName = "Pagination";
4386
4390
  var Pagination_default = Pagination;
4387
4391
 
4388
4392
  // src/components/DataTable/DataTable.tsx
4393
+ var _columnsVersionCache = /* @__PURE__ */ new WeakMap();
4394
+ var _columnsVersionCounter = 0;
4395
+ function getColumnsVersion(columns) {
4396
+ if (!_columnsVersionCache.has(columns)) {
4397
+ _columnsVersionCache.set(columns, ++_columnsVersionCounter);
4398
+ }
4399
+ return _columnsVersionCache.get(columns);
4400
+ }
4401
+ var EMPTY_CHECKBOX_PROPS = {};
4389
4402
  function Component(props, apiRef) {
4390
4403
  const {
4391
4404
  rows,
@@ -4433,7 +4446,7 @@ function Component(props, apiRef) {
4433
4446
  noRowsOverlay: NoRowsOverlay = DefaultNoRowsOverlay
4434
4447
  } = {},
4435
4448
  slotProps: {
4436
- checkbox: checkboxProps = {},
4449
+ checkbox: checkboxProps = EMPTY_CHECKBOX_PROPS,
4437
4450
  toolbar: toolbarProps,
4438
4451
  background: backgroundProps = {},
4439
4452
  noRowsOverlay: noRowsOverlayProps = {}
@@ -4481,6 +4494,28 @@ function Component(props, apiRef) {
4481
4494
  overscan: 10
4482
4495
  });
4483
4496
  const paginationModel = useMemo10(() => ({ page, pageSize }), [page, pageSize]);
4497
+ const columnsKey = getColumnsVersion(columns);
4498
+ const headerCheckboxElement = useMemo10(
4499
+ () => /* @__PURE__ */ React25.createElement(
4500
+ RenderCheckbox,
4501
+ {
4502
+ onChange: onAllCheckboxChange,
4503
+ checked: isAllSelected,
4504
+ indeterminate: (selectionModel || []).length > 0 && !isAllSelected,
4505
+ disabled: dataInPage.length > 0 && !selectableRowCount,
4506
+ ...checkboxProps
4507
+ }
4508
+ ),
4509
+ [
4510
+ RenderCheckbox,
4511
+ onAllCheckboxChange,
4512
+ isAllSelected,
4513
+ selectionModel,
4514
+ selectableRowCount,
4515
+ dataInPage.length,
4516
+ checkboxProps
4517
+ ]
4518
+ );
4484
4519
  const totalSize = virtualizer.getTotalSize();
4485
4520
  const virtualizedItems = virtualizer.getVirtualItems();
4486
4521
  const showNoRowsOverlay = !loading && rowCount === 0;
@@ -4685,16 +4720,7 @@ function Component(props, apiRef) {
4685
4720
  verticalAlign: "middle"
4686
4721
  }
4687
4722
  },
4688
- /* @__PURE__ */ React25.createElement(
4689
- RenderCheckbox,
4690
- {
4691
- onChange: onAllCheckboxChange,
4692
- checked: isAllSelected,
4693
- indeterminate: (selectionModel || []).length > 0 && !isAllSelected,
4694
- disabled: dataInPage.length > 0 && !selectableRowCount,
4695
- ...checkboxProps
4696
- }
4697
- )
4723
+ headerCheckboxElement
4698
4724
  ), level > 0 && Array.from({ length: levelGroups[0]?.startIndex || 0 }).map((_2, i) => /* @__PURE__ */ React25.createElement("th", { key: `empty-${level}-${i}` })), levelGroups.filter((g) => g.colspan > 0).map((group, groupIndex) => {
4699
4725
  const nextGroup = levelGroups[groupIndex + 1];
4700
4726
  const emptyCells = nextGroup ? nextGroup.startIndex - (group.startIndex + group.colspan) : columns.length - (group.startIndex + group.colspan);
@@ -4721,16 +4747,7 @@ function Component(props, apiRef) {
4721
4747
  textAlign: "center"
4722
4748
  }
4723
4749
  },
4724
- /* @__PURE__ */ React25.createElement(
4725
- RenderCheckbox,
4726
- {
4727
- onChange: onAllCheckboxChange,
4728
- checked: isAllSelected,
4729
- indeterminate: (selectionModel || []).length > 0 && !isAllSelected,
4730
- disabled: dataInPage.length > 0 && !selectableRowCount,
4731
- ...checkboxProps
4732
- }
4733
- )
4750
+ headerCheckboxElement
4734
4751
  ), columns.map((c, i) => (
4735
4752
  // @ts-ignore
4736
4753
  /* @__PURE__ */ React25.createElement(
@@ -4801,6 +4818,7 @@ function Component(props, apiRef) {
4801
4818
  key: virtualizedRow.key,
4802
4819
  "data-row-id": rowId,
4803
4820
  "data-index": rowIndex,
4821
+ "data-columns-key": columnsKey,
4804
4822
  "aria-rowindex": rowIndex + 1,
4805
4823
  role: checkboxSelection && !disableSelectionOnClick ? "checkbox" : void 0,
4806
4824
  tabIndex: focusedRowId === rowId ? 0 : -1,