@ceed/cds 1.4.1 → 1.4.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
@@ -2961,7 +2961,7 @@ var VirtualizedTableBody = (0, import_joy33.styled)("tbody", {
2961
2961
  height: "0.01em"
2962
2962
  }
2963
2963
  });
2964
- var VirtualizedTableRow = (0, import_joy33.styled)("tr", {
2964
+ var StyledTableRow = (0, import_joy33.styled)("tr", {
2965
2965
  name: "DataTable",
2966
2966
  slot: "tableRow",
2967
2967
  shouldForwardProp: (prop) => prop !== "striped"
@@ -2980,6 +2980,12 @@ var VirtualizedTableRow = (0, import_joy33.styled)("tr", {
2980
2980
  }
2981
2981
  }
2982
2982
  }));
2983
+ var VirtualizedTableRow = (0, import_react25.memo)(StyledTableRow, (prevProps, nextProps) => {
2984
+ return prevProps.striped === nextProps.striped && prevProps.style?.height === nextProps.style?.height && prevProps.style?.transform === nextProps.style?.transform && // @ts-ignore
2985
+ prevProps["data-row-id"] === nextProps["data-row-id"] && // @ts-ignore
2986
+ prevProps["data-index"] === nextProps["data-index"] && prevProps.tabIndex === nextProps.tabIndex && prevProps["aria-checked"] === nextProps["aria-checked"] && // Include children check to handle isCellEditable changes
2987
+ prevProps.children === nextProps.children;
2988
+ });
2983
2989
  var Asterisk = (0, import_joy33.styled)("span", {
2984
2990
  name: "DataTable",
2985
2991
  slot: "headCellAsterisk"
@@ -3713,6 +3719,31 @@ function Component(props, apiRef) {
3713
3719
  const paginationModel = (0, import_react25.useMemo)(() => ({ page, pageSize }), [page, pageSize]);
3714
3720
  const totalSize = virtualizer.getTotalSize();
3715
3721
  const virtualizedItems = virtualizer.getVirtualItems();
3722
+ const getRowClickHandler = (0, import_react25.useCallback)(
3723
+ (row, rowId) => (e) => {
3724
+ onRowClick?.({ row, rowId }, e);
3725
+ checkboxSelection && !disableSelectionOnClick && onCheckboxChange(e, rowId);
3726
+ },
3727
+ [onRowClick, checkboxSelection, disableSelectionOnClick, onCheckboxChange]
3728
+ );
3729
+ const getRowFocusHandler = (0, import_react25.useCallback)(
3730
+ (rowId) => () => {
3731
+ onRowFocus(rowId);
3732
+ },
3733
+ [onRowFocus]
3734
+ );
3735
+ const getCheckboxClickHandler = (0, import_react25.useCallback)(
3736
+ () => (e) => {
3737
+ e.stopPropagation();
3738
+ },
3739
+ []
3740
+ );
3741
+ const getCheckboxChangeHandler = (0, import_react25.useCallback)(
3742
+ (rowId) => (e) => {
3743
+ onCheckboxChange(e, rowId);
3744
+ },
3745
+ [onCheckboxChange]
3746
+ );
3716
3747
  (0, import_react25.useImperativeHandle)(apiRef, () => ({
3717
3748
  getRowIndexRelativeToVisibleRows(rowId) {
3718
3749
  return dataInPage.findIndex((row) => String(getId(row)) === rowId);
@@ -3851,12 +3882,9 @@ function Component(props, apiRef) {
3851
3882
  "data-index": rowIndex,
3852
3883
  role: checkboxSelection && !disableSelectionOnClick ? "checkbox" : void 0,
3853
3884
  tabIndex: focusedRowId === rowId ? 0 : -1,
3854
- onClick: (e) => {
3855
- onRowClick?.({ row, rowId }, e);
3856
- checkboxSelection && !disableSelectionOnClick && onCheckboxChange(e, rowId);
3857
- },
3858
- onFocus: () => onRowFocus(rowId),
3859
- "aria-checked": checkboxSelection && !disableSelectionOnClick ? isSelectedRow(rowId) : void 0,
3885
+ onClick: getRowClickHandler(row, rowId),
3886
+ onFocus: getRowFocusHandler(rowId),
3887
+ "aria-checked": checkboxSelection ? isSelectedRow(rowId) : void 0,
3860
3888
  striped,
3861
3889
  style: {
3862
3890
  height: `${virtualizedRow.size}px`,
@@ -3874,8 +3902,8 @@ function Component(props, apiRef) {
3874
3902
  /* @__PURE__ */ import_react25.default.createElement(
3875
3903
  RenderCheckbox,
3876
3904
  {
3877
- onClick: (e) => e.stopPropagation(),
3878
- onChange: (e) => onCheckboxChange(e, rowId),
3905
+ onClick: getCheckboxClickHandler(),
3906
+ onChange: getCheckboxChangeHandler(rowId),
3879
3907
  checked: isSelectedRow(rowId),
3880
3908
  ...checkboxProps
3881
3909
  }
package/dist/index.js CHANGED
@@ -2922,7 +2922,7 @@ var VirtualizedTableBody = styled12("tbody", {
2922
2922
  height: "0.01em"
2923
2923
  }
2924
2924
  });
2925
- var VirtualizedTableRow = styled12("tr", {
2925
+ var StyledTableRow = styled12("tr", {
2926
2926
  name: "DataTable",
2927
2927
  slot: "tableRow",
2928
2928
  shouldForwardProp: (prop) => prop !== "striped"
@@ -2941,6 +2941,12 @@ var VirtualizedTableRow = styled12("tr", {
2941
2941
  }
2942
2942
  }
2943
2943
  }));
2944
+ var VirtualizedTableRow = memo(StyledTableRow, (prevProps, nextProps) => {
2945
+ return prevProps.striped === nextProps.striped && prevProps.style?.height === nextProps.style?.height && prevProps.style?.transform === nextProps.style?.transform && // @ts-ignore
2946
+ prevProps["data-row-id"] === nextProps["data-row-id"] && // @ts-ignore
2947
+ prevProps["data-index"] === nextProps["data-index"] && prevProps.tabIndex === nextProps.tabIndex && prevProps["aria-checked"] === nextProps["aria-checked"] && // Include children check to handle isCellEditable changes
2948
+ prevProps.children === nextProps.children;
2949
+ });
2944
2950
  var Asterisk = styled12("span", {
2945
2951
  name: "DataTable",
2946
2952
  slot: "headCellAsterisk"
@@ -3674,6 +3680,31 @@ function Component(props, apiRef) {
3674
3680
  const paginationModel = useMemo8(() => ({ page, pageSize }), [page, pageSize]);
3675
3681
  const totalSize = virtualizer.getTotalSize();
3676
3682
  const virtualizedItems = virtualizer.getVirtualItems();
3683
+ const getRowClickHandler = useCallback9(
3684
+ (row, rowId) => (e) => {
3685
+ onRowClick?.({ row, rowId }, e);
3686
+ checkboxSelection && !disableSelectionOnClick && onCheckboxChange(e, rowId);
3687
+ },
3688
+ [onRowClick, checkboxSelection, disableSelectionOnClick, onCheckboxChange]
3689
+ );
3690
+ const getRowFocusHandler = useCallback9(
3691
+ (rowId) => () => {
3692
+ onRowFocus(rowId);
3693
+ },
3694
+ [onRowFocus]
3695
+ );
3696
+ const getCheckboxClickHandler = useCallback9(
3697
+ () => (e) => {
3698
+ e.stopPropagation();
3699
+ },
3700
+ []
3701
+ );
3702
+ const getCheckboxChangeHandler = useCallback9(
3703
+ (rowId) => (e) => {
3704
+ onCheckboxChange(e, rowId);
3705
+ },
3706
+ [onCheckboxChange]
3707
+ );
3677
3708
  useImperativeHandle2(apiRef, () => ({
3678
3709
  getRowIndexRelativeToVisibleRows(rowId) {
3679
3710
  return dataInPage.findIndex((row) => String(getId(row)) === rowId);
@@ -3812,12 +3843,9 @@ function Component(props, apiRef) {
3812
3843
  "data-index": rowIndex,
3813
3844
  role: checkboxSelection && !disableSelectionOnClick ? "checkbox" : void 0,
3814
3845
  tabIndex: focusedRowId === rowId ? 0 : -1,
3815
- onClick: (e) => {
3816
- onRowClick?.({ row, rowId }, e);
3817
- checkboxSelection && !disableSelectionOnClick && onCheckboxChange(e, rowId);
3818
- },
3819
- onFocus: () => onRowFocus(rowId),
3820
- "aria-checked": checkboxSelection && !disableSelectionOnClick ? isSelectedRow(rowId) : void 0,
3846
+ onClick: getRowClickHandler(row, rowId),
3847
+ onFocus: getRowFocusHandler(rowId),
3848
+ "aria-checked": checkboxSelection ? isSelectedRow(rowId) : void 0,
3821
3849
  striped,
3822
3850
  style: {
3823
3851
  height: `${virtualizedRow.size}px`,
@@ -3835,8 +3863,8 @@ function Component(props, apiRef) {
3835
3863
  /* @__PURE__ */ React23.createElement(
3836
3864
  RenderCheckbox,
3837
3865
  {
3838
- onClick: (e) => e.stopPropagation(),
3839
- onChange: (e) => onCheckboxChange(e, rowId),
3866
+ onClick: getCheckboxClickHandler(),
3867
+ onChange: getCheckboxChangeHandler(rowId),
3840
3868
  checked: isSelectedRow(rowId),
3841
3869
  ...checkboxProps
3842
3870
  }