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

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
@@ -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
  });
@@ -4026,22 +4028,28 @@ function useDataTableRenderer({
4026
4028
  ),
4027
4029
  [reorderedColumns]
4028
4030
  );
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) => {
4031
+ const columnIdByColumn = (0, import_react27.useMemo)(() => {
4032
+ const taken = new Set(reorderedColumns.map((column) => String(column.field)));
4033
+ const assigned = /* @__PURE__ */ new Set();
4034
+ const ids = /* @__PURE__ */ new Map();
4035
+ reorderedColumns.forEach((column) => {
4033
4036
  const field = String(column.field);
4034
- if (!ids.includes(field)) {
4035
- ids.push(field);
4037
+ if (!assigned.has(field)) {
4038
+ assigned.add(field);
4039
+ ids.set(column, field);
4036
4040
  return;
4037
4041
  }
4038
4042
  let n = 2;
4039
4043
  while (taken.has(`${field}__${n}`)) n += 1;
4040
4044
  taken.add(`${field}__${n}`);
4041
- ids.push(`${field}__${n}`);
4045
+ ids.set(column, `${field}__${n}`);
4042
4046
  });
4043
4047
  return ids;
4044
- }, [visibleColumns]);
4048
+ }, [reorderedColumns]);
4049
+ const columnIds = (0, import_react27.useMemo)(
4050
+ () => visibleColumns.map((column) => columnIdByColumn.get(column) ?? String(column.field)),
4051
+ [visibleColumns, columnIdByColumn]
4052
+ );
4045
4053
  const visibleColumnsById = (0, import_react27.useMemo)(
4046
4054
  () => Object.fromEntries(
4047
4055
  visibleColumns.map((column, index) => [
package/dist/index.js CHANGED
@@ -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
  });
@@ -3911,22 +3913,28 @@ function useDataTableRenderer({
3911
3913
  ),
3912
3914
  [reorderedColumns]
3913
3915
  );
3914
- const columnIds = useMemo11(() => {
3915
- const taken = new Set(visibleColumns.map((column) => String(column.field)));
3916
- const ids = [];
3917
- visibleColumns.forEach((column) => {
3916
+ const columnIdByColumn = useMemo11(() => {
3917
+ const taken = new Set(reorderedColumns.map((column) => String(column.field)));
3918
+ const assigned = /* @__PURE__ */ new Set();
3919
+ const ids = /* @__PURE__ */ new Map();
3920
+ reorderedColumns.forEach((column) => {
3918
3921
  const field = String(column.field);
3919
- if (!ids.includes(field)) {
3920
- ids.push(field);
3922
+ if (!assigned.has(field)) {
3923
+ assigned.add(field);
3924
+ ids.set(column, field);
3921
3925
  return;
3922
3926
  }
3923
3927
  let n = 2;
3924
3928
  while (taken.has(`${field}__${n}`)) n += 1;
3925
3929
  taken.add(`${field}__${n}`);
3926
- ids.push(`${field}__${n}`);
3930
+ ids.set(column, `${field}__${n}`);
3927
3931
  });
3928
3932
  return ids;
3929
- }, [visibleColumns]);
3933
+ }, [reorderedColumns]);
3934
+ const columnIds = useMemo11(
3935
+ () => visibleColumns.map((column) => columnIdByColumn.get(column) ?? String(column.field)),
3936
+ [visibleColumns, columnIdByColumn]
3937
+ );
3930
3938
  const visibleColumnsById = useMemo11(
3931
3939
  () => Object.fromEntries(
3932
3940
  visibleColumns.map((column, index) => [