@ceed/cds 1.40.3-next.6 → 1.40.3-next.7
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/components/DataTable/utils.d.ts +6 -0
- package/dist/index.browser.js +6 -6
- package/dist/index.browser.js.map +3 -3
- package/dist/index.cjs +23 -11
- package/dist/index.js +151 -139
- package/dist/libs/slot-props.d.ts +2 -2
- package/framer/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -460,16 +460,25 @@ function useSlotRef(slotProp, ref) {
|
|
|
460
460
|
const isFunctionForm = typeof slotProp === "function";
|
|
461
461
|
const slotRef = isFunctionForm ? void 0 : slotProp?.ref;
|
|
462
462
|
const mergedRef = useMergedRef(slotRef, ref);
|
|
463
|
+
const latestSlotRef = (0, import_react6.useRef)(null);
|
|
464
|
+
const stableMergedRef = (0, import_react6.useCallback)(
|
|
465
|
+
(value) => {
|
|
466
|
+
assignRef(latestSlotRef.current, value);
|
|
467
|
+
assignRef(ref, value);
|
|
468
|
+
},
|
|
469
|
+
[ref]
|
|
470
|
+
);
|
|
463
471
|
return (0, import_react6.useMemo)(() => {
|
|
464
472
|
if (isFunctionForm) {
|
|
465
473
|
return ((ownerState) => {
|
|
466
474
|
const resolved = slotProp(ownerState) ?? {};
|
|
467
|
-
const
|
|
468
|
-
|
|
475
|
+
const resolvedRef = resolved.ref;
|
|
476
|
+
latestSlotRef.current = resolvedRef ?? null;
|
|
477
|
+
return resolvedRef || ref ? { ...resolved, ref: stableMergedRef } : { ...resolved };
|
|
469
478
|
});
|
|
470
479
|
}
|
|
471
480
|
return mergedRef ? { ...slotProp, ref: mergedRef } : { ...slotProp };
|
|
472
|
-
}, [isFunctionForm, slotProp, mergedRef, ref]);
|
|
481
|
+
}, [isFunctionForm, slotProp, mergedRef, ref, stableMergedRef]);
|
|
473
482
|
}
|
|
474
483
|
|
|
475
484
|
// src/components/Autocomplete/Autocomplete.tsx
|
|
@@ -2612,7 +2621,10 @@ function computeAutoFitWidth(params) {
|
|
|
2612
2621
|
return finalWidth;
|
|
2613
2622
|
}
|
|
2614
2623
|
function getHeaderCellId(tableId, columnId) {
|
|
2615
|
-
return `${tableId}_header_${columnId}
|
|
2624
|
+
return `${tableId}_header_${columnId}`;
|
|
2625
|
+
}
|
|
2626
|
+
function sanitizeColumnId(field) {
|
|
2627
|
+
return String(field).trim().replace(/\s+/g, "_");
|
|
2616
2628
|
}
|
|
2617
2629
|
|
|
2618
2630
|
// src/components/DataTable/styled.tsx
|
|
@@ -3950,8 +3962,8 @@ function useColumnWidths(columnsById) {
|
|
|
3950
3962
|
});
|
|
3951
3963
|
setWidths((prev) => {
|
|
3952
3964
|
const keys = Object.keys(measured);
|
|
3953
|
-
const same = keys.
|
|
3954
|
-
return same ? prev : measured;
|
|
3965
|
+
const same = keys.every((key) => prev[key] === measured[key]);
|
|
3966
|
+
return same ? prev : { ...prev, ...measured };
|
|
3955
3967
|
});
|
|
3956
3968
|
return () => roRef.current?.disconnect();
|
|
3957
3969
|
}, [columnsById]);
|
|
@@ -4038,10 +4050,10 @@ function useDataTableRenderer({
|
|
|
4038
4050
|
[reorderedColumns]
|
|
4039
4051
|
);
|
|
4040
4052
|
const allColumnIds = (0, import_react27.useMemo)(() => {
|
|
4041
|
-
const taken = new Set(reorderedColumns.map((column) =>
|
|
4053
|
+
const taken = new Set(reorderedColumns.map((column) => sanitizeColumnId(column.field)));
|
|
4042
4054
|
const assigned = /* @__PURE__ */ new Set();
|
|
4043
4055
|
return reorderedColumns.map((column) => {
|
|
4044
|
-
const field =
|
|
4056
|
+
const field = sanitizeColumnId(column.field);
|
|
4045
4057
|
if (!assigned.has(field)) {
|
|
4046
4058
|
assigned.add(field);
|
|
4047
4059
|
return field;
|
|
@@ -4192,7 +4204,7 @@ function useDataTableRenderer({
|
|
|
4192
4204
|
field: key
|
|
4193
4205
|
}));
|
|
4194
4206
|
return baseColumns.map((column, index) => {
|
|
4195
|
-
const columnId = columnIds[index] ??
|
|
4207
|
+
const columnId = columnIds[index] ?? sanitizeColumnId(column.field);
|
|
4196
4208
|
const isLeftPinned = effectivePinnedLeft?.includes(column.field);
|
|
4197
4209
|
const isRightPinned = effectivePinnedRight?.includes(column.field);
|
|
4198
4210
|
const isPinned = isLeftPinned || isRightPinned;
|
|
@@ -5030,13 +5042,13 @@ function Component(props, apiRef) {
|
|
|
5030
5042
|
}
|
|
5031
5043
|
},
|
|
5032
5044
|
headerCheckboxElement
|
|
5033
|
-
), columns.map((c
|
|
5045
|
+
), columns.map((c) => (
|
|
5034
5046
|
// @ts-ignore
|
|
5035
5047
|
/* @__PURE__ */ import_react30.default.createElement(
|
|
5036
5048
|
HeadCell2,
|
|
5037
5049
|
{
|
|
5038
5050
|
tableId,
|
|
5039
|
-
key:
|
|
5051
|
+
key: c.columnId,
|
|
5040
5052
|
stickyHeader: props.stickyHeader,
|
|
5041
5053
|
editMode: !!c.isCellEditable,
|
|
5042
5054
|
onSortChange: handleSortChange,
|