@ceed/cds 1.40.3-next.2 → 1.40.3-next.4

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
@@ -463,7 +463,7 @@ function useSlotRef(slotProp, ref) {
463
463
  return (0, import_react6.useMemo)(() => {
464
464
  if (isFunctionForm) {
465
465
  return ((ownerState) => {
466
- const resolved = slotProp(ownerState);
466
+ const resolved = slotProp(ownerState) ?? {};
467
467
  const merged = mergeRefs(resolved.ref, ref);
468
468
  return merged ? { ...resolved, ref: merged } : { ...resolved };
469
469
  });
@@ -3926,6 +3926,7 @@ function useColumnWidths(columnsById) {
3926
3926
  entries.forEach((entry) => {
3927
3927
  const columnId = entry.target.dataset.hdsColumnId;
3928
3928
  const w = Math.round(entry.target.getBoundingClientRect().width);
3929
+ if (w === 0) return;
3929
3930
  if (next[columnId] !== w) {
3930
3931
  next[columnId] = w;
3931
3932
  changed = true;
@@ -3940,7 +3941,8 @@ function useColumnWidths(columnsById) {
3940
3941
  if (el) {
3941
3942
  el.dataset.hdsColumnId = columnId;
3942
3943
  el.dataset.field = String(def.field);
3943
- measured[columnId] = Math.round(el.getBoundingClientRect().width);
3944
+ const w = Math.round(el.getBoundingClientRect().width);
3945
+ if (w > 0) measured[columnId] = w;
3944
3946
  roRef.current.observe(el);
3945
3947
  }
3946
3948
  });
@@ -4003,10 +4005,17 @@ function useDataTableRenderer({
4003
4005
  if (!columnGroupingModel) return columnsProp;
4004
4006
  return reorderColumnsByGroupingModel(columnsProp, columnGroupingModel);
4005
4007
  }, [columnsProp, columnGroupingModel]);
4006
- const visibleColumns = (0, import_react27.useMemo)(
4007
- () => reorderedColumns.filter((col) => visibilityModel[col.field] !== false),
4008
+ const visibleColumnIndexes = (0, import_react27.useMemo)(
4009
+ () => reorderedColumns.reduce((acc, col, index) => {
4010
+ if (visibilityModel[col.field] !== false) acc.push(index);
4011
+ return acc;
4012
+ }, []),
4008
4013
  [reorderedColumns, visibilityModel]
4009
4014
  );
4015
+ const visibleColumns = (0, import_react27.useMemo)(
4016
+ () => visibleColumnIndexes.map((index) => reorderedColumns[index]),
4017
+ [visibleColumnIndexes, reorderedColumns]
4018
+ );
4010
4019
  const visibleFieldSet = (0, import_react27.useMemo)(() => new Set(visibleColumns.map((c) => c.field)), [visibleColumns]);
4011
4020
  const tableMinWidth = (0, import_react27.useMemo)(() => {
4012
4021
  const DEFAULT_MIN = 50;
@@ -4026,22 +4035,25 @@ function useDataTableRenderer({
4026
4035
  ),
4027
4036
  [reorderedColumns]
4028
4037
  );
4029
- const columnIds = (0, import_react27.useMemo)(() => {
4030
- const taken = new Set(visibleColumns.map((column) => String(column.field)));
4031
- const ids = [];
4032
- visibleColumns.forEach((column) => {
4038
+ const allColumnIds = (0, import_react27.useMemo)(() => {
4039
+ const taken = new Set(reorderedColumns.map((column) => String(column.field)));
4040
+ const assigned = /* @__PURE__ */ new Set();
4041
+ return reorderedColumns.map((column) => {
4033
4042
  const field = String(column.field);
4034
- if (!ids.includes(field)) {
4035
- ids.push(field);
4036
- return;
4043
+ if (!assigned.has(field)) {
4044
+ assigned.add(field);
4045
+ return field;
4037
4046
  }
4038
4047
  let n = 2;
4039
4048
  while (taken.has(`${field}__${n}`)) n += 1;
4040
4049
  taken.add(`${field}__${n}`);
4041
- ids.push(`${field}__${n}`);
4050
+ return `${field}__${n}`;
4042
4051
  });
4043
- return ids;
4044
- }, [visibleColumns]);
4052
+ }, [reorderedColumns]);
4053
+ const columnIds = (0, import_react27.useMemo)(
4054
+ () => visibleColumnIndexes.map((index) => allColumnIds[index]),
4055
+ [visibleColumnIndexes, allColumnIds]
4056
+ );
4045
4057
  const visibleColumnsById = (0, import_react27.useMemo)(
4046
4058
  () => Object.fromEntries(
4047
4059
  visibleColumns.map((column, index) => [
package/dist/index.js CHANGED
@@ -316,7 +316,7 @@ function useSlotRef(slotProp, ref) {
316
316
  return useMemo(() => {
317
317
  if (isFunctionForm) {
318
318
  return ((ownerState) => {
319
- const resolved = slotProp(ownerState);
319
+ const resolved = slotProp(ownerState) ?? {};
320
320
  const merged = mergeRefs(resolved.ref, ref);
321
321
  return merged ? { ...resolved, ref: merged } : { ...resolved };
322
322
  });
@@ -3811,6 +3811,7 @@ function useColumnWidths(columnsById) {
3811
3811
  entries.forEach((entry) => {
3812
3812
  const columnId = entry.target.dataset.hdsColumnId;
3813
3813
  const w = Math.round(entry.target.getBoundingClientRect().width);
3814
+ if (w === 0) return;
3814
3815
  if (next[columnId] !== w) {
3815
3816
  next[columnId] = w;
3816
3817
  changed = true;
@@ -3825,7 +3826,8 @@ function useColumnWidths(columnsById) {
3825
3826
  if (el) {
3826
3827
  el.dataset.hdsColumnId = columnId;
3827
3828
  el.dataset.field = String(def.field);
3828
- measured[columnId] = Math.round(el.getBoundingClientRect().width);
3829
+ const w = Math.round(el.getBoundingClientRect().width);
3830
+ if (w > 0) measured[columnId] = w;
3829
3831
  roRef.current.observe(el);
3830
3832
  }
3831
3833
  });
@@ -3888,10 +3890,17 @@ function useDataTableRenderer({
3888
3890
  if (!columnGroupingModel) return columnsProp;
3889
3891
  return reorderColumnsByGroupingModel(columnsProp, columnGroupingModel);
3890
3892
  }, [columnsProp, columnGroupingModel]);
3891
- const visibleColumns = useMemo11(
3892
- () => reorderedColumns.filter((col) => visibilityModel[col.field] !== false),
3893
+ const visibleColumnIndexes = useMemo11(
3894
+ () => reorderedColumns.reduce((acc, col, index) => {
3895
+ if (visibilityModel[col.field] !== false) acc.push(index);
3896
+ return acc;
3897
+ }, []),
3893
3898
  [reorderedColumns, visibilityModel]
3894
3899
  );
3900
+ const visibleColumns = useMemo11(
3901
+ () => visibleColumnIndexes.map((index) => reorderedColumns[index]),
3902
+ [visibleColumnIndexes, reorderedColumns]
3903
+ );
3895
3904
  const visibleFieldSet = useMemo11(() => new Set(visibleColumns.map((c) => c.field)), [visibleColumns]);
3896
3905
  const tableMinWidth = useMemo11(() => {
3897
3906
  const DEFAULT_MIN = 50;
@@ -3911,22 +3920,25 @@ function useDataTableRenderer({
3911
3920
  ),
3912
3921
  [reorderedColumns]
3913
3922
  );
3914
- const columnIds = useMemo11(() => {
3915
- const taken = new Set(visibleColumns.map((column) => String(column.field)));
3916
- const ids = [];
3917
- visibleColumns.forEach((column) => {
3923
+ const allColumnIds = useMemo11(() => {
3924
+ const taken = new Set(reorderedColumns.map((column) => String(column.field)));
3925
+ const assigned = /* @__PURE__ */ new Set();
3926
+ return reorderedColumns.map((column) => {
3918
3927
  const field = String(column.field);
3919
- if (!ids.includes(field)) {
3920
- ids.push(field);
3921
- return;
3928
+ if (!assigned.has(field)) {
3929
+ assigned.add(field);
3930
+ return field;
3922
3931
  }
3923
3932
  let n = 2;
3924
3933
  while (taken.has(`${field}__${n}`)) n += 1;
3925
3934
  taken.add(`${field}__${n}`);
3926
- ids.push(`${field}__${n}`);
3935
+ return `${field}__${n}`;
3927
3936
  });
3928
- return ids;
3929
- }, [visibleColumns]);
3937
+ }, [reorderedColumns]);
3938
+ const columnIds = useMemo11(
3939
+ () => visibleColumnIndexes.map((index) => allColumnIds[index]),
3940
+ [visibleColumnIndexes, allColumnIds]
3941
+ );
3930
3942
  const visibleColumnsById = useMemo11(
3931
3943
  () => Object.fromEntries(
3932
3944
  visibleColumns.map((column, index) => [