@gobolt/genesis 0.4.10 → 0.4.12
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/Table/Table.d.ts +8 -1
- package/dist/index.cjs +130 -63
- package/dist/index.js +130 -63
- package/package.json +1 -1
|
@@ -46,6 +46,13 @@ export interface TableProps<T extends Record<string, any>> {
|
|
|
46
46
|
isMainContentCell?: boolean;
|
|
47
47
|
isMaterializedView?: boolean;
|
|
48
48
|
materializedViewConfig?: MaterializedViewConfig<T>;
|
|
49
|
+
enableRowKeyValidation?: boolean;
|
|
50
|
+
onRowKeyError?: (error: {
|
|
51
|
+
record: T;
|
|
52
|
+
rowKey: keyof T | ((record: T) => React.Key);
|
|
53
|
+
index: number;
|
|
54
|
+
error: Error;
|
|
55
|
+
}) => void;
|
|
49
56
|
}
|
|
50
57
|
export type TablePaginationType = {
|
|
51
58
|
pageSize?: number;
|
|
@@ -59,5 +66,5 @@ export type SorterResult<T> = {
|
|
|
59
66
|
field?: keyof T | string | React.Key | readonly React.Key[];
|
|
60
67
|
columnKey?: React.Key;
|
|
61
68
|
};
|
|
62
|
-
declare function Table<T extends Record<string, any>>({ columns, dataSource, rowKey, size, onChange, rowSelection, onRowClick, pagination, isMainContentCell, isMaterializedView, materializedViewConfig, ...rest }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
69
|
+
declare function Table<T extends Record<string, any>>({ columns, dataSource, rowKey, size, onChange, rowSelection, onRowClick, pagination, isMainContentCell, isMaterializedView, materializedViewConfig, enableRowKeyValidation, onRowKeyError, ...rest }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
63
70
|
export default Table;
|
package/dist/index.cjs
CHANGED
|
@@ -49300,8 +49300,8 @@ function Column$2(_) {
|
|
|
49300
49300
|
function ColumnGroup$1(_) {
|
|
49301
49301
|
return null;
|
|
49302
49302
|
}
|
|
49303
|
-
function fillRecords(list2, record, indent, childrenColumnName, expandedKeys,
|
|
49304
|
-
var key =
|
|
49303
|
+
function fillRecords(list2, record, indent, childrenColumnName, expandedKeys, getRowKey2, index2) {
|
|
49304
|
+
var key = getRowKey2(record, index2);
|
|
49305
49305
|
list2.push({
|
|
49306
49306
|
record,
|
|
49307
49307
|
indent,
|
|
@@ -49311,17 +49311,17 @@ function fillRecords(list2, record, indent, childrenColumnName, expandedKeys, ge
|
|
|
49311
49311
|
var expanded = expandedKeys === null || expandedKeys === void 0 ? void 0 : expandedKeys.has(key);
|
|
49312
49312
|
if (record && Array.isArray(record[childrenColumnName]) && expanded) {
|
|
49313
49313
|
for (var i = 0; i < record[childrenColumnName].length; i += 1) {
|
|
49314
|
-
fillRecords(list2, record[childrenColumnName][i], indent + 1, childrenColumnName, expandedKeys,
|
|
49314
|
+
fillRecords(list2, record[childrenColumnName][i], indent + 1, childrenColumnName, expandedKeys, getRowKey2, i);
|
|
49315
49315
|
}
|
|
49316
49316
|
}
|
|
49317
49317
|
}
|
|
49318
|
-
function useFlattenRecords(data, childrenColumnName, expandedKeys,
|
|
49318
|
+
function useFlattenRecords(data, childrenColumnName, expandedKeys, getRowKey2) {
|
|
49319
49319
|
var arr = React__namespace.useMemo(function() {
|
|
49320
49320
|
if (expandedKeys !== null && expandedKeys !== void 0 && expandedKeys.size) {
|
|
49321
49321
|
var list2 = [];
|
|
49322
49322
|
for (var i = 0; i < (data === null || data === void 0 ? void 0 : data.length); i += 1) {
|
|
49323
49323
|
var record = data[i];
|
|
49324
|
-
fillRecords(list2, record, 0, childrenColumnName, expandedKeys,
|
|
49324
|
+
fillRecords(list2, record, 0, childrenColumnName, expandedKeys, getRowKey2, i);
|
|
49325
49325
|
}
|
|
49326
49326
|
return list2;
|
|
49327
49327
|
}
|
|
@@ -49330,10 +49330,10 @@ function useFlattenRecords(data, childrenColumnName, expandedKeys, getRowKey) {
|
|
|
49330
49330
|
record: item,
|
|
49331
49331
|
indent: 0,
|
|
49332
49332
|
index: index2,
|
|
49333
|
-
rowKey:
|
|
49333
|
+
rowKey: getRowKey2(item, index2)
|
|
49334
49334
|
};
|
|
49335
49335
|
});
|
|
49336
|
-
}, [data, childrenColumnName, expandedKeys,
|
|
49336
|
+
}, [data, childrenColumnName, expandedKeys, getRowKey2]);
|
|
49337
49337
|
return arr;
|
|
49338
49338
|
}
|
|
49339
49339
|
function useRowInfo(record, rowKey, recordIndex, indent) {
|
|
@@ -49424,11 +49424,11 @@ function renderExpandIcon$1(_ref) {
|
|
|
49424
49424
|
onClick
|
|
49425
49425
|
});
|
|
49426
49426
|
}
|
|
49427
|
-
function findAllChildrenKeys(data,
|
|
49427
|
+
function findAllChildrenKeys(data, getRowKey2, childrenColumnName) {
|
|
49428
49428
|
var keys2 = [];
|
|
49429
49429
|
function dig(list2) {
|
|
49430
49430
|
(list2 || []).forEach(function(item, index2) {
|
|
49431
|
-
keys2.push(
|
|
49431
|
+
keys2.push(getRowKey2(item, index2));
|
|
49432
49432
|
dig(item[childrenColumnName]);
|
|
49433
49433
|
});
|
|
49434
49434
|
}
|
|
@@ -49603,8 +49603,8 @@ function Body(props) {
|
|
|
49603
49603
|
devRenderTimes(props);
|
|
49604
49604
|
}
|
|
49605
49605
|
var data = props.data, measureColumnWidth = props.measureColumnWidth;
|
|
49606
|
-
var _useContext = useContext(TableContext, ["prefixCls", "getComponent", "onColumnResize", "flattenColumns", "getRowKey", "expandedKeys", "childrenColumnName", "emptyNode", "expandedRowOffset", "fixedInfoList", "colWidths"]), prefixCls = _useContext.prefixCls, getComponent = _useContext.getComponent, onColumnResize = _useContext.onColumnResize, flattenColumns = _useContext.flattenColumns,
|
|
49607
|
-
var flattenData2 = useFlattenRecords(data, childrenColumnName, expandedKeys,
|
|
49606
|
+
var _useContext = useContext(TableContext, ["prefixCls", "getComponent", "onColumnResize", "flattenColumns", "getRowKey", "expandedKeys", "childrenColumnName", "emptyNode", "expandedRowOffset", "fixedInfoList", "colWidths"]), prefixCls = _useContext.prefixCls, getComponent = _useContext.getComponent, onColumnResize = _useContext.onColumnResize, flattenColumns = _useContext.flattenColumns, getRowKey2 = _useContext.getRowKey, expandedKeys = _useContext.expandedKeys, childrenColumnName = _useContext.childrenColumnName, emptyNode = _useContext.emptyNode, _useContext$expandedR = _useContext.expandedRowOffset, expandedRowOffset = _useContext$expandedR === void 0 ? 0 : _useContext$expandedR, colWidths = _useContext.colWidths;
|
|
49607
|
+
var flattenData2 = useFlattenRecords(data, childrenColumnName, expandedKeys, getRowKey2);
|
|
49608
49608
|
var rowKeys = React__namespace.useMemo(function() {
|
|
49609
49609
|
return flattenData2.map(function(item) {
|
|
49610
49610
|
return item.rowKey;
|
|
@@ -50073,7 +50073,7 @@ function revertForRtl(columns) {
|
|
|
50073
50073
|
});
|
|
50074
50074
|
}
|
|
50075
50075
|
function useColumns(_ref2, transformColumns) {
|
|
50076
|
-
var prefixCls = _ref2.prefixCls, columns = _ref2.columns, children2 = _ref2.children, expandable = _ref2.expandable, expandedKeys = _ref2.expandedKeys, columnTitle = _ref2.columnTitle,
|
|
50076
|
+
var prefixCls = _ref2.prefixCls, columns = _ref2.columns, children2 = _ref2.children, expandable = _ref2.expandable, expandedKeys = _ref2.expandedKeys, columnTitle = _ref2.columnTitle, getRowKey2 = _ref2.getRowKey, onTriggerExpand = _ref2.onTriggerExpand, expandIcon = _ref2.expandIcon, rowExpandable = _ref2.rowExpandable, expandIconColumnIndex = _ref2.expandIconColumnIndex, _ref2$expandedRowOffs = _ref2.expandedRowOffset, expandedRowOffset = _ref2$expandedRowOffs === void 0 ? 0 : _ref2$expandedRowOffs, direction = _ref2.direction, expandRowByClick = _ref2.expandRowByClick, columnWidth = _ref2.columnWidth, fixed = _ref2.fixed, scrollWidth = _ref2.scrollWidth, clientWidth = _ref2.clientWidth;
|
|
50077
50077
|
var baseColumns = React__namespace.useMemo(function() {
|
|
50078
50078
|
var newColumns = columns || convertChildrenToColumns(children2) || [];
|
|
50079
50079
|
return filterHiddenColumns(newColumns.slice());
|
|
@@ -50113,7 +50113,7 @@ function useColumns(_ref2, transformColumns) {
|
|
|
50113
50113
|
className: "".concat(prefixCls, "-expand-icon-col"),
|
|
50114
50114
|
columnType: "EXPAND_COLUMN"
|
|
50115
50115
|
}), "title", columnTitle), "fixed", fixedColumn), "className", "".concat(prefixCls, "-row-expand-icon-cell")), "width", columnWidth), "render", function render2(_, record, index2) {
|
|
50116
|
-
var rowKey =
|
|
50116
|
+
var rowKey = getRowKey2(record, index2);
|
|
50117
50117
|
var expanded = expandedKeys.has(rowKey);
|
|
50118
50118
|
var recordExpandable = rowExpandable ? rowExpandable(record) : true;
|
|
50119
50119
|
var icon = expandIcon({
|
|
@@ -50148,7 +50148,7 @@ function useColumns(_ref2, transformColumns) {
|
|
|
50148
50148
|
return baseColumns.filter(function(col) {
|
|
50149
50149
|
return col !== EXPAND_COLUMN;
|
|
50150
50150
|
});
|
|
50151
|
-
}, [expandable, baseColumns,
|
|
50151
|
+
}, [expandable, baseColumns, getRowKey2, expandedKeys, expandIcon, direction, expandedRowOffset]);
|
|
50152
50152
|
var mergedColumns = React__namespace.useMemo(function() {
|
|
50153
50153
|
var finalColumns = withExpandColumns;
|
|
50154
50154
|
if (transformColumns) {
|
|
@@ -50203,7 +50203,7 @@ function useColumns(_ref2, transformColumns) {
|
|
|
50203
50203
|
var _useWidthColumns = useWidthColumns(flattenColumns, scrollWidth, clientWidth), _useWidthColumns2 = _slicedToArray(_useWidthColumns, 2), filledColumns = _useWidthColumns2[0], realScrollWidth = _useWidthColumns2[1];
|
|
50204
50204
|
return [mergedColumns, filledColumns, realScrollWidth, hasGapFixed];
|
|
50205
50205
|
}
|
|
50206
|
-
function useExpand(props, mergedData,
|
|
50206
|
+
function useExpand(props, mergedData, getRowKey2) {
|
|
50207
50207
|
var expandableConfig = getExpandableProps(props);
|
|
50208
50208
|
var expandIcon = expandableConfig.expandIcon, expandedRowKeys = expandableConfig.expandedRowKeys, defaultExpandedRowKeys = expandableConfig.defaultExpandedRowKeys, defaultExpandAllRows = expandableConfig.defaultExpandAllRows, expandedRowRender = expandableConfig.expandedRowRender, onExpand = expandableConfig.onExpand, onExpandedRowsChange = expandableConfig.onExpandedRowsChange, childrenColumnName = expandableConfig.childrenColumnName;
|
|
50209
50209
|
var mergedExpandIcon = expandIcon || renderExpandIcon$1;
|
|
@@ -50224,7 +50224,7 @@ function useExpand(props, mergedData, getRowKey) {
|
|
|
50224
50224
|
return defaultExpandedRowKeys;
|
|
50225
50225
|
}
|
|
50226
50226
|
if (defaultExpandAllRows) {
|
|
50227
|
-
return findAllChildrenKeys(mergedData,
|
|
50227
|
+
return findAllChildrenKeys(mergedData, getRowKey2, mergedChildrenColumnName);
|
|
50228
50228
|
}
|
|
50229
50229
|
return [];
|
|
50230
50230
|
}), _React$useState2 = _slicedToArray(_React$useState, 2), innerExpandedKeys = _React$useState2[0], setInnerExpandedKeys = _React$useState2[1];
|
|
@@ -50232,7 +50232,7 @@ function useExpand(props, mergedData, getRowKey) {
|
|
|
50232
50232
|
return new Set(expandedRowKeys || innerExpandedKeys || []);
|
|
50233
50233
|
}, [expandedRowKeys, innerExpandedKeys]);
|
|
50234
50234
|
var onTriggerExpand = React__namespace.useCallback(function(record) {
|
|
50235
|
-
var key =
|
|
50235
|
+
var key = getRowKey2(record, mergedData.indexOf(record));
|
|
50236
50236
|
var newExpandedKeys;
|
|
50237
50237
|
var hasKey = mergedExpandedKeys.has(key);
|
|
50238
50238
|
if (hasKey) {
|
|
@@ -50248,7 +50248,7 @@ function useExpand(props, mergedData, getRowKey) {
|
|
|
50248
50248
|
if (onExpandedRowsChange) {
|
|
50249
50249
|
onExpandedRowsChange(newExpandedKeys);
|
|
50250
50250
|
}
|
|
50251
|
-
}, [
|
|
50251
|
+
}, [getRowKey2, mergedExpandedKeys, mergedData, onExpand, onExpandedRowsChange]);
|
|
50252
50252
|
if (process.env.NODE_ENV !== "production" && expandedRowRender && mergedData.some(function(record) {
|
|
50253
50253
|
return Array.isArray(record === null || record === void 0 ? void 0 : record[mergedChildrenColumnName]);
|
|
50254
50254
|
})) {
|
|
@@ -50568,7 +50568,7 @@ function Table$3(tableProps, ref) {
|
|
|
50568
50568
|
var getComponent = React__namespace.useCallback(function(path2, defaultComponent) {
|
|
50569
50569
|
return get$2(components2, path2) || defaultComponent;
|
|
50570
50570
|
}, [components2]);
|
|
50571
|
-
var
|
|
50571
|
+
var getRowKey2 = React__namespace.useMemo(function() {
|
|
50572
50572
|
if (typeof rowKey === "function") {
|
|
50573
50573
|
return rowKey;
|
|
50574
50574
|
}
|
|
@@ -50582,14 +50582,14 @@ function Table$3(tableProps, ref) {
|
|
|
50582
50582
|
}, [rowKey]);
|
|
50583
50583
|
var customizeScrollBody = getComponent(["body"]);
|
|
50584
50584
|
var _useHover = useHover(), _useHover2 = _slicedToArray(_useHover, 3), startRow = _useHover2[0], endRow = _useHover2[1], onHover = _useHover2[2];
|
|
50585
|
-
var _useExpand = useExpand(props, mergedData,
|
|
50585
|
+
var _useExpand = useExpand(props, mergedData, getRowKey2), _useExpand2 = _slicedToArray(_useExpand, 6), expandableConfig = _useExpand2[0], expandableType = _useExpand2[1], mergedExpandedKeys = _useExpand2[2], mergedExpandIcon = _useExpand2[3], mergedChildrenColumnName = _useExpand2[4], onTriggerExpand = _useExpand2[5];
|
|
50586
50586
|
var scrollX = scroll === null || scroll === void 0 ? void 0 : scroll.x;
|
|
50587
50587
|
var _React$useState = React__namespace.useState(0), _React$useState2 = _slicedToArray(_React$useState, 2), componentWidth = _React$useState2[0], setComponentWidth = _React$useState2[1];
|
|
50588
50588
|
var _useColumns = useColumns(_objectSpread2(_objectSpread2(_objectSpread2({}, props), expandableConfig), {}, {
|
|
50589
50589
|
expandable: !!expandableConfig.expandedRowRender,
|
|
50590
50590
|
columnTitle: expandableConfig.columnTitle,
|
|
50591
50591
|
expandedKeys: mergedExpandedKeys,
|
|
50592
|
-
getRowKey,
|
|
50592
|
+
getRowKey: getRowKey2,
|
|
50593
50593
|
// https://github.com/ant-design/ant-design/issues/23894
|
|
50594
50594
|
onTriggerExpand,
|
|
50595
50595
|
expandIcon: mergedExpandIcon,
|
|
@@ -50623,7 +50623,7 @@ function Table$3(tableProps, ref) {
|
|
|
50623
50623
|
});
|
|
50624
50624
|
} else {
|
|
50625
50625
|
var _scrollBodyRef$curren2;
|
|
50626
|
-
var mergedKey = key !== null && key !== void 0 ? key :
|
|
50626
|
+
var mergedKey = key !== null && key !== void 0 ? key : getRowKey2(mergedData[index2]);
|
|
50627
50627
|
(_scrollBodyRef$curren2 = scrollBodyRef.current.querySelector('[data-row-key="'.concat(mergedKey, '"]'))) === null || _scrollBodyRef$curren2 === void 0 || _scrollBodyRef$curren2.scrollIntoView();
|
|
50628
50628
|
}
|
|
50629
50629
|
} else if ((_scrollBodyRef$curren3 = scrollBodyRef.current) !== null && _scrollBodyRef$curren3 !== void 0 && _scrollBodyRef$curren3.scrollTo) {
|
|
@@ -50989,7 +50989,7 @@ function Table$3(tableProps, ref) {
|
|
|
50989
50989
|
onHover,
|
|
50990
50990
|
rowExpandable: expandableConfig.rowExpandable,
|
|
50991
50991
|
onRow,
|
|
50992
|
-
getRowKey,
|
|
50992
|
+
getRowKey: getRowKey2,
|
|
50993
50993
|
expandedKeys: mergedExpandedKeys,
|
|
50994
50994
|
childrenColumnName: mergedChildrenColumnName,
|
|
50995
50995
|
rowHoverable
|
|
@@ -51033,7 +51033,7 @@ function Table$3(tableProps, ref) {
|
|
|
51033
51033
|
onHover,
|
|
51034
51034
|
expandableConfig.rowExpandable,
|
|
51035
51035
|
onRow,
|
|
51036
|
-
|
|
51036
|
+
getRowKey2,
|
|
51037
51037
|
mergedExpandedKeys,
|
|
51038
51038
|
mergedChildrenColumnName,
|
|
51039
51039
|
rowHoverable
|
|
@@ -51187,10 +51187,10 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
51187
51187
|
}
|
|
51188
51188
|
var Grid = /* @__PURE__ */ React__namespace.forwardRef(function(props, ref) {
|
|
51189
51189
|
var data = props.data, onScroll = props.onScroll;
|
|
51190
|
-
var _useContext = useContext(TableContext, ["flattenColumns", "onColumnResize", "getRowKey", "prefixCls", "expandedKeys", "childrenColumnName", "scrollX", "direction"]), flattenColumns = _useContext.flattenColumns, onColumnResize = _useContext.onColumnResize,
|
|
51190
|
+
var _useContext = useContext(TableContext, ["flattenColumns", "onColumnResize", "getRowKey", "prefixCls", "expandedKeys", "childrenColumnName", "scrollX", "direction"]), flattenColumns = _useContext.flattenColumns, onColumnResize = _useContext.onColumnResize, getRowKey2 = _useContext.getRowKey, expandedKeys = _useContext.expandedKeys, prefixCls = _useContext.prefixCls, childrenColumnName = _useContext.childrenColumnName, scrollX = _useContext.scrollX, direction = _useContext.direction;
|
|
51191
51191
|
var _useContext2 = useContext(StaticContext), sticky = _useContext2.sticky, scrollY = _useContext2.scrollY, listItemHeight = _useContext2.listItemHeight, getComponent = _useContext2.getComponent, onTablePropScroll = _useContext2.onScroll;
|
|
51192
51192
|
var listRef = React__namespace.useRef();
|
|
51193
|
-
var flattenData2 = useFlattenRecords(data, childrenColumnName, expandedKeys,
|
|
51193
|
+
var flattenData2 = useFlattenRecords(data, childrenColumnName, expandedKeys, getRowKey2);
|
|
51194
51194
|
var columnsWidth = React__namespace.useMemo(function() {
|
|
51195
51195
|
var total = 0;
|
|
51196
51196
|
return flattenColumns.map(function(_ref) {
|
|
@@ -51304,10 +51304,10 @@ var Grid = /* @__PURE__ */ React__namespace.forwardRef(function(props, ref) {
|
|
|
51304
51304
|
}
|
|
51305
51305
|
var nodes = spanLines.map(function(index2) {
|
|
51306
51306
|
var item = flattenData2[index2];
|
|
51307
|
-
var rowKey =
|
|
51307
|
+
var rowKey = getRowKey2(item.record, index2);
|
|
51308
51308
|
var getHeight2 = function getHeight3(rowSpan) {
|
|
51309
51309
|
var endItemIndex = index2 + rowSpan - 1;
|
|
51310
|
-
var endItemKey =
|
|
51310
|
+
var endItemKey = getRowKey2(flattenData2[endItemIndex].record, endItemIndex);
|
|
51311
51311
|
var sizeInfo2 = getSize3(rowKey, endItemKey);
|
|
51312
51312
|
return sizeInfo2.bottom - sizeInfo2.top;
|
|
51313
51313
|
};
|
|
@@ -51355,7 +51355,7 @@ var Grid = /* @__PURE__ */ React__namespace.forwardRef(function(props, ref) {
|
|
|
51355
51355
|
itemHeight: listItemHeight || 24,
|
|
51356
51356
|
data: flattenData2,
|
|
51357
51357
|
itemKey: function itemKey2(item) {
|
|
51358
|
-
return
|
|
51358
|
+
return getRowKey2(item.record);
|
|
51359
51359
|
},
|
|
51360
51360
|
component: wrapperComponent,
|
|
51361
51361
|
scrollWidth: scrollX,
|
|
@@ -51371,7 +51371,7 @@ var Grid = /* @__PURE__ */ React__namespace.forwardRef(function(props, ref) {
|
|
|
51371
51371
|
onScroll: onTablePropScroll,
|
|
51372
51372
|
extraRender
|
|
51373
51373
|
}, function(item, index2, itemProps) {
|
|
51374
|
-
var rowKey =
|
|
51374
|
+
var rowKey = getRowKey2(item.record, index2);
|
|
51375
51375
|
return /* @__PURE__ */ React__namespace.createElement(ResponseBodyLine, {
|
|
51376
51376
|
data: item,
|
|
51377
51377
|
rowKey,
|
|
@@ -51988,7 +51988,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
51988
51988
|
data,
|
|
51989
51989
|
pageData,
|
|
51990
51990
|
getRecordByKey,
|
|
51991
|
-
getRowKey,
|
|
51991
|
+
getRowKey: getRowKey2,
|
|
51992
51992
|
expandType,
|
|
51993
51993
|
childrenColumnName,
|
|
51994
51994
|
locale: tableLocale,
|
|
@@ -52027,35 +52027,35 @@ const useSelection = (config, rowSelection) => {
|
|
|
52027
52027
|
}
|
|
52028
52028
|
let convertData = data;
|
|
52029
52029
|
if (preserveSelectedRowKeys) {
|
|
52030
|
-
const keysSet = new Set(flattedData.map((record, index2) =>
|
|
52030
|
+
const keysSet = new Set(flattedData.map((record, index2) => getRowKey2(record, index2)));
|
|
52031
52031
|
const preserveRecords = Array.from(preserveRecordsRef.current).reduce((total, [key, value2]) => keysSet.has(key) ? total : total.concat(value2), []);
|
|
52032
52032
|
convertData = [].concat(_toConsumableArray(convertData), _toConsumableArray(preserveRecords));
|
|
52033
52033
|
}
|
|
52034
52034
|
return convertDataToEntities(convertData, {
|
|
52035
|
-
externalGetKey:
|
|
52035
|
+
externalGetKey: getRowKey2,
|
|
52036
52036
|
childrenPropName: childrenColumnName
|
|
52037
52037
|
});
|
|
52038
|
-
}, [data,
|
|
52038
|
+
}, [data, getRowKey2, checkStrictly, childrenColumnName, preserveSelectedRowKeys, flattedData]);
|
|
52039
52039
|
const checkboxPropsMap = React.useMemo(() => {
|
|
52040
52040
|
const map2 = /* @__PURE__ */ new Map();
|
|
52041
52041
|
flattedData.forEach((record, index2) => {
|
|
52042
|
-
const key =
|
|
52042
|
+
const key = getRowKey2(record, index2);
|
|
52043
52043
|
const checkboxProps = (getCheckboxProps ? getCheckboxProps(record) : null) || {};
|
|
52044
52044
|
map2.set(key, checkboxProps);
|
|
52045
52045
|
process.env.NODE_ENV !== "production" ? warning3(!("checked" in checkboxProps || "defaultChecked" in checkboxProps), "usage", "Do not set `checked` or `defaultChecked` in `getCheckboxProps`. Please use `selectedRowKeys` instead.") : void 0;
|
|
52046
52046
|
});
|
|
52047
52047
|
return map2;
|
|
52048
|
-
}, [flattedData,
|
|
52048
|
+
}, [flattedData, getRowKey2, getCheckboxProps]);
|
|
52049
52049
|
const isCheckboxDisabled = React.useCallback((r2) => {
|
|
52050
|
-
const rowKey =
|
|
52050
|
+
const rowKey = getRowKey2(r2);
|
|
52051
52051
|
let checkboxProps;
|
|
52052
52052
|
if (checkboxPropsMap.has(rowKey)) {
|
|
52053
|
-
checkboxProps = checkboxPropsMap.get(
|
|
52053
|
+
checkboxProps = checkboxPropsMap.get(getRowKey2(r2));
|
|
52054
52054
|
} else {
|
|
52055
52055
|
checkboxProps = getCheckboxProps ? getCheckboxProps(r2) : void 0;
|
|
52056
52056
|
}
|
|
52057
52057
|
return !!(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.disabled);
|
|
52058
|
-
}, [checkboxPropsMap,
|
|
52058
|
+
}, [checkboxPropsMap, getRowKey2]);
|
|
52059
52059
|
const [derivedSelectedKeys, derivedHalfSelectedKeys] = React.useMemo(() => {
|
|
52060
52060
|
if (checkStrictly) {
|
|
52061
52061
|
return [mergedSelectedKeys || [], []];
|
|
@@ -52117,7 +52117,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52117
52117
|
key: "all",
|
|
52118
52118
|
text: tableLocale.selectionAll,
|
|
52119
52119
|
onSelect() {
|
|
52120
|
-
setSelectedKeys(data.map((record, index2) =>
|
|
52120
|
+
setSelectedKeys(data.map((record, index2) => getRowKey2(record, index2)).filter((key) => {
|
|
52121
52121
|
const checkProps = checkboxPropsMap.get(key);
|
|
52122
52122
|
return !(checkProps === null || checkProps === void 0 ? void 0 : checkProps.disabled) || derivedSelectedKeySet.has(key);
|
|
52123
52123
|
}), "all");
|
|
@@ -52131,7 +52131,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52131
52131
|
onSelect() {
|
|
52132
52132
|
const keySet = new Set(derivedSelectedKeySet);
|
|
52133
52133
|
pageData.forEach((record, index2) => {
|
|
52134
|
-
const key =
|
|
52134
|
+
const key = getRowKey2(record, index2);
|
|
52135
52135
|
const checkProps = checkboxPropsMap.get(key);
|
|
52136
52136
|
if (!(checkProps === null || checkProps === void 0 ? void 0 : checkProps.disabled)) {
|
|
52137
52137
|
if (keySet.has(key)) {
|
|
@@ -52172,7 +52172,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52172
52172
|
updatePrevSelectedIndex(null);
|
|
52173
52173
|
}
|
|
52174
52174
|
}));
|
|
52175
|
-
}, [selections, derivedSelectedKeySet, pageData,
|
|
52175
|
+
}, [selections, derivedSelectedKeySet, pageData, getRowKey2, onSelectInvert, setSelectedKeys]);
|
|
52176
52176
|
const transformColumns = React.useCallback((columns) => {
|
|
52177
52177
|
var _a;
|
|
52178
52178
|
if (!rowSelection) {
|
|
@@ -52181,7 +52181,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52181
52181
|
}
|
|
52182
52182
|
let cloneColumns = _toConsumableArray(columns);
|
|
52183
52183
|
const keySet = new Set(derivedSelectedKeySet);
|
|
52184
|
-
const recordKeys = flattedData.map(
|
|
52184
|
+
const recordKeys = flattedData.map(getRowKey2).filter((key) => !checkboxPropsMap.get(key).disabled);
|
|
52185
52185
|
const checkedCurrentAll = recordKeys.every((key) => keySet.has(key));
|
|
52186
52186
|
const checkedCurrentSome = recordKeys.some((key) => keySet.has(key));
|
|
52187
52187
|
const onSelectAllChange = () => {
|
|
@@ -52234,7 +52234,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52234
52234
|
}, /* @__PURE__ */ React__namespace.createElement("span", null, /* @__PURE__ */ React__namespace.createElement(RefIcon$w, null))));
|
|
52235
52235
|
}
|
|
52236
52236
|
const allDisabledData = flattedData.map((record, index2) => {
|
|
52237
|
-
const key =
|
|
52237
|
+
const key = getRowKey2(record, index2);
|
|
52238
52238
|
const checkboxProps = checkboxPropsMap.get(key) || {};
|
|
52239
52239
|
return Object.assign({
|
|
52240
52240
|
checked: keySet.has(key)
|
|
@@ -52273,7 +52273,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52273
52273
|
let renderCell;
|
|
52274
52274
|
if (selectionType === "radio") {
|
|
52275
52275
|
renderCell = (_, record, index2) => {
|
|
52276
|
-
const key =
|
|
52276
|
+
const key = getRowKey2(record, index2);
|
|
52277
52277
|
const checked = keySet.has(key);
|
|
52278
52278
|
const checkboxProps = checkboxPropsMap.get(key);
|
|
52279
52279
|
return {
|
|
@@ -52298,7 +52298,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52298
52298
|
} else {
|
|
52299
52299
|
renderCell = (_, record, index2) => {
|
|
52300
52300
|
var _a2;
|
|
52301
|
-
const key =
|
|
52301
|
+
const key = getRowKey2(record, index2);
|
|
52302
52302
|
const checked = keySet.has(key);
|
|
52303
52303
|
const indeterminate = derivedHalfSelectedKeySet.has(key);
|
|
52304
52304
|
const checkboxProps = checkboxPropsMap.get(key);
|
|
@@ -52430,7 +52430,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52430
52430
|
}
|
|
52431
52431
|
};
|
|
52432
52432
|
return cloneColumns.map((col) => col === SELECTION_COLUMN ? selectionColumn : col);
|
|
52433
|
-
}, [
|
|
52433
|
+
}, [getRowKey2, flattedData, rowSelection, derivedSelectedKeys, derivedSelectedKeySet, derivedHalfSelectedKeySet, selectionColWidth, mergedSelections, expandType, checkboxPropsMap, onSelectMultiple, triggerSingleSelection, isCheckboxDisabled]);
|
|
52434
52434
|
return [transformColumns, derivedSelectedKeySet];
|
|
52435
52435
|
};
|
|
52436
52436
|
function fillProxy(element2, handler) {
|
|
@@ -55310,14 +55310,14 @@ const useFilter = (props) => {
|
|
|
55310
55310
|
const transformColumns = (innerColumns) => injectFilter(prefixCls, dropdownPrefixCls, innerColumns, mergedFilterStates, tableLocale, triggerFilter, getPopupContainer, void 0, rootClassName);
|
|
55311
55311
|
return [transformColumns, mergedFilterStates, filters];
|
|
55312
55312
|
};
|
|
55313
|
-
const useLazyKVMap = (data, childrenColumnName,
|
|
55313
|
+
const useLazyKVMap = (data, childrenColumnName, getRowKey2) => {
|
|
55314
55314
|
const mapCacheRef = React__namespace.useRef({});
|
|
55315
55315
|
function getRecordByKey(key) {
|
|
55316
55316
|
var _a;
|
|
55317
|
-
if (!mapCacheRef.current || mapCacheRef.current.data !== data || mapCacheRef.current.childrenColumnName !== childrenColumnName || mapCacheRef.current.getRowKey !==
|
|
55317
|
+
if (!mapCacheRef.current || mapCacheRef.current.data !== data || mapCacheRef.current.childrenColumnName !== childrenColumnName || mapCacheRef.current.getRowKey !== getRowKey2) {
|
|
55318
55318
|
let dig = function(records) {
|
|
55319
55319
|
records.forEach((record, index2) => {
|
|
55320
|
-
const rowKey =
|
|
55320
|
+
const rowKey = getRowKey2(record, index2);
|
|
55321
55321
|
kvMap.set(rowKey, record);
|
|
55322
55322
|
if (record && typeof record === "object" && childrenColumnName in record) {
|
|
55323
55323
|
dig(record[childrenColumnName] || []);
|
|
@@ -55330,7 +55330,7 @@ const useLazyKVMap = (data, childrenColumnName, getRowKey) => {
|
|
|
55330
55330
|
data,
|
|
55331
55331
|
childrenColumnName,
|
|
55332
55332
|
kvMap,
|
|
55333
|
-
getRowKey
|
|
55333
|
+
getRowKey: getRowKey2
|
|
55334
55334
|
};
|
|
55335
55335
|
}
|
|
55336
55336
|
return (_a = mapCacheRef.current.kvMap) === null || _a === void 0 ? void 0 : _a.get(key);
|
|
@@ -57238,13 +57238,13 @@ const InternalTable = (props, ref) => {
|
|
|
57238
57238
|
useProxyImperativeHandle(ref, () => Object.assign(Object.assign({}, tblRef.current), {
|
|
57239
57239
|
nativeElement: rootRef.current
|
|
57240
57240
|
}));
|
|
57241
|
-
const
|
|
57241
|
+
const getRowKey2 = React__namespace.useMemo(() => {
|
|
57242
57242
|
if (typeof rowKey === "function") {
|
|
57243
57243
|
return rowKey;
|
|
57244
57244
|
}
|
|
57245
57245
|
return (record) => record === null || record === void 0 ? void 0 : record[rowKey];
|
|
57246
57246
|
}, [rowKey]);
|
|
57247
|
-
const [getRecordByKey] = useLazyKVMap(rawData, childrenColumnName,
|
|
57247
|
+
const [getRecordByKey] = useLazyKVMap(rawData, childrenColumnName, getRowKey2);
|
|
57248
57248
|
const changeEventInfo = {};
|
|
57249
57249
|
const triggerOnChange = (info, action, reset = false) => {
|
|
57250
57250
|
var _a2, _b2, _c, _d;
|
|
@@ -57349,7 +57349,7 @@ const InternalTable = (props, ref) => {
|
|
|
57349
57349
|
prefixCls,
|
|
57350
57350
|
data: mergedData,
|
|
57351
57351
|
pageData,
|
|
57352
|
-
getRowKey,
|
|
57352
|
+
getRowKey: getRowKey2,
|
|
57353
57353
|
getRecordByKey,
|
|
57354
57354
|
expandType,
|
|
57355
57355
|
childrenColumnName,
|
|
@@ -57364,7 +57364,7 @@ const InternalTable = (props, ref) => {
|
|
|
57364
57364
|
mergedRowClassName = classNames(rowClassName);
|
|
57365
57365
|
}
|
|
57366
57366
|
return classNames({
|
|
57367
|
-
[`${prefixCls}-row-selected`]: selectedKeySet.has(
|
|
57367
|
+
[`${prefixCls}-row-selected`]: selectedKeySet.has(getRowKey2(record, index2))
|
|
57368
57368
|
}, mergedRowClassName);
|
|
57369
57369
|
};
|
|
57370
57370
|
mergedExpandable.__PARENT_RENDER_ICON__ = mergedExpandable.expandIcon;
|
|
@@ -57472,7 +57472,7 @@ const InternalTable = (props, ref) => {
|
|
|
57472
57472
|
[`${prefixCls}-empty`]: rawData.length === 0
|
|
57473
57473
|
}, cssVarCls, rootCls, hashId),
|
|
57474
57474
|
data: pageData,
|
|
57475
|
-
rowKey:
|
|
57475
|
+
rowKey: getRowKey2,
|
|
57476
57476
|
rowClassName: internalRowClassName,
|
|
57477
57477
|
emptyText,
|
|
57478
57478
|
// Internal
|
|
@@ -83976,6 +83976,39 @@ function requireDebounce() {
|
|
|
83976
83976
|
}
|
|
83977
83977
|
var debounceExports = /* @__PURE__ */ requireDebounce();
|
|
83978
83978
|
const debounce = /* @__PURE__ */ getDefaultExportFromCjs(debounceExports);
|
|
83979
|
+
const getRowKey = (record, rowKey, index2, enableValidation = true) => {
|
|
83980
|
+
try {
|
|
83981
|
+
const key = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
|
|
83982
|
+
if (enableValidation) {
|
|
83983
|
+
if (key === void 0 || key === null) {
|
|
83984
|
+
console.error(`Genesis Table: rowKey "${String(rowKey)}" returned undefined/null for record at index ${index2}.`, {
|
|
83985
|
+
record,
|
|
83986
|
+
rowKey,
|
|
83987
|
+
availableKeys: Object.keys(record)
|
|
83988
|
+
});
|
|
83989
|
+
return `fallback-${index2}`;
|
|
83990
|
+
}
|
|
83991
|
+
if (typeof key === "string" && String(key).trim() === "") {
|
|
83992
|
+
console.warn(`Genesis Table: rowKey "${String(rowKey)}" returned empty string for record at index ${index2}.`, {
|
|
83993
|
+
record,
|
|
83994
|
+
rowKey
|
|
83995
|
+
});
|
|
83996
|
+
return `fallback-${index2}`;
|
|
83997
|
+
}
|
|
83998
|
+
}
|
|
83999
|
+
return key;
|
|
84000
|
+
} catch (error2) {
|
|
84001
|
+
if (enableValidation) {
|
|
84002
|
+
console.error(`Genesis Table: Error accessing rowKey "${String(rowKey)}" for record at index ${index2}.`, {
|
|
84003
|
+
error: error2,
|
|
84004
|
+
record,
|
|
84005
|
+
rowKey,
|
|
84006
|
+
availableKeys: Object.keys(record)
|
|
84007
|
+
});
|
|
84008
|
+
}
|
|
84009
|
+
return `fallback-${index2}`;
|
|
84010
|
+
}
|
|
84011
|
+
};
|
|
83979
84012
|
function Table({
|
|
83980
84013
|
columns,
|
|
83981
84014
|
dataSource,
|
|
@@ -83988,6 +84021,8 @@ function Table({
|
|
|
83988
84021
|
isMainContentCell = false,
|
|
83989
84022
|
isMaterializedView = false,
|
|
83990
84023
|
materializedViewConfig,
|
|
84024
|
+
enableRowKeyValidation = process.env.NODE_ENV === "development",
|
|
84025
|
+
onRowKeyError,
|
|
83991
84026
|
...rest
|
|
83992
84027
|
}) {
|
|
83993
84028
|
const [materializedData, setMaterializedData] = React__namespace.useState([]);
|
|
@@ -84102,6 +84137,42 @@ function Table({
|
|
|
84102
84137
|
return rest.scroll;
|
|
84103
84138
|
}, [isMaterializedView, materializedViewConfig, dynamicHeight, rest.scroll]);
|
|
84104
84139
|
const tableDataSource = isMaterializedView ? materializedData : dataSource;
|
|
84140
|
+
React__namespace.useEffect(() => {
|
|
84141
|
+
if (enableRowKeyValidation && tableDataSource.length > 0) {
|
|
84142
|
+
const sampleRecord = tableDataSource[0];
|
|
84143
|
+
if (typeof rowKey === "string") {
|
|
84144
|
+
if (!(rowKey in sampleRecord)) {
|
|
84145
|
+
const error2 = new Error(`rowKey "${rowKey}" does not exist in data records`);
|
|
84146
|
+
console.error(`Genesis Table: ${error2.message}. Available keys:`, Object.keys(sampleRecord));
|
|
84147
|
+
onRowKeyError?.({
|
|
84148
|
+
record: sampleRecord,
|
|
84149
|
+
rowKey,
|
|
84150
|
+
index: 0,
|
|
84151
|
+
error: error2
|
|
84152
|
+
});
|
|
84153
|
+
}
|
|
84154
|
+
}
|
|
84155
|
+
const keys2 = tableDataSource.map(
|
|
84156
|
+
(record, index2) => getRowKey(record, rowKey, index2, false)
|
|
84157
|
+
// Don't log individual errors here
|
|
84158
|
+
);
|
|
84159
|
+
const uniqueKeys = [...new Set(keys2)];
|
|
84160
|
+
if (keys2.length !== uniqueKeys.length) {
|
|
84161
|
+
const error2 = new Error(`Duplicate row keys detected`);
|
|
84162
|
+
console.error(`Genesis Table: ${error2.message}!`, {
|
|
84163
|
+
totalKeys: keys2.length,
|
|
84164
|
+
uniqueKeys: uniqueKeys.length,
|
|
84165
|
+
duplicates: keys2.filter((key, index2) => keys2.indexOf(key) !== index2)
|
|
84166
|
+
});
|
|
84167
|
+
onRowKeyError?.({
|
|
84168
|
+
record: tableDataSource[0],
|
|
84169
|
+
rowKey,
|
|
84170
|
+
index: 0,
|
|
84171
|
+
error: error2
|
|
84172
|
+
});
|
|
84173
|
+
}
|
|
84174
|
+
}
|
|
84175
|
+
}, [tableDataSource, rowKey, enableRowKeyValidation, onRowKeyError]);
|
|
84105
84176
|
const handleRowMouseDown = React__namespace.useCallback(
|
|
84106
84177
|
(record, index2, event) => {
|
|
84107
84178
|
const target = event.target;
|
|
@@ -84111,10 +84182,10 @@ function Table({
|
|
|
84111
84182
|
if (isInteractiveElement) {
|
|
84112
84183
|
return;
|
|
84113
84184
|
}
|
|
84114
|
-
const recordKey =
|
|
84185
|
+
const recordKey = getRowKey(record, rowKey, index2, enableRowKeyValidation);
|
|
84115
84186
|
setPressedRowKey(recordKey);
|
|
84116
84187
|
},
|
|
84117
|
-
[rowKey]
|
|
84188
|
+
[rowKey, enableRowKeyValidation]
|
|
84118
84189
|
);
|
|
84119
84190
|
const handleRowMouseUp = React__namespace.useCallback(
|
|
84120
84191
|
(record, index2, event) => {
|
|
@@ -84124,14 +84195,11 @@ function Table({
|
|
|
84124
84195
|
);
|
|
84125
84196
|
const handleRowClick = React__namespace.useCallback(
|
|
84126
84197
|
(record, index2, event) => {
|
|
84127
|
-
console.log("Row clicked:", record, "index:", index2);
|
|
84128
84198
|
const target = event.target;
|
|
84129
84199
|
const isInteractiveElement = target.closest(
|
|
84130
84200
|
'button, a, input, select, textarea, [role="button"], [onclick], .ant-checkbox-wrapper, .ant-checkbox'
|
|
84131
84201
|
);
|
|
84132
|
-
console.log("Is interactive element:", isInteractiveElement);
|
|
84133
84202
|
if (isInteractiveElement) {
|
|
84134
|
-
console.log("Skipping row click due to interactive element");
|
|
84135
84203
|
return;
|
|
84136
84204
|
}
|
|
84137
84205
|
if (onRowClick) {
|
|
@@ -84148,7 +84216,6 @@ function Table({
|
|
|
84148
84216
|
// Use internal state
|
|
84149
84217
|
// Override the onChange to ensure we get the latest data
|
|
84150
84218
|
onChange: (selectedRowKeys2, selectedRows) => {
|
|
84151
|
-
console.log("Row selection changed:", selectedRowKeys2, selectedRows);
|
|
84152
84219
|
setSelectedRowKeys(selectedRowKeys2);
|
|
84153
84220
|
if (rowSelection.onChange) {
|
|
84154
84221
|
rowSelection.onChange(selectedRowKeys2, selectedRows);
|
|
@@ -84170,7 +84237,7 @@ function Table({
|
|
|
84170
84237
|
rowSelection: enhancedRowSelection,
|
|
84171
84238
|
onRow: (record, index2) => {
|
|
84172
84239
|
const isDisabled = rowSelection?.getCheckboxProps?.(record)?.disabled ?? false;
|
|
84173
|
-
const recordKey =
|
|
84240
|
+
const recordKey = getRowKey(record, rowKey, index2 ?? 0, enableRowKeyValidation);
|
|
84174
84241
|
const isPressed = pressedRowKey === recordKey;
|
|
84175
84242
|
return {
|
|
84176
84243
|
onClick: (event) => handleRowClick(record, index2 ?? 0, event),
|
package/dist/index.js
CHANGED
|
@@ -49282,8 +49282,8 @@ function Column$2(_) {
|
|
|
49282
49282
|
function ColumnGroup$1(_) {
|
|
49283
49283
|
return null;
|
|
49284
49284
|
}
|
|
49285
|
-
function fillRecords(list2, record, indent, childrenColumnName, expandedKeys,
|
|
49286
|
-
var key =
|
|
49285
|
+
function fillRecords(list2, record, indent, childrenColumnName, expandedKeys, getRowKey2, index2) {
|
|
49286
|
+
var key = getRowKey2(record, index2);
|
|
49287
49287
|
list2.push({
|
|
49288
49288
|
record,
|
|
49289
49289
|
indent,
|
|
@@ -49293,17 +49293,17 @@ function fillRecords(list2, record, indent, childrenColumnName, expandedKeys, ge
|
|
|
49293
49293
|
var expanded = expandedKeys === null || expandedKeys === void 0 ? void 0 : expandedKeys.has(key);
|
|
49294
49294
|
if (record && Array.isArray(record[childrenColumnName]) && expanded) {
|
|
49295
49295
|
for (var i = 0; i < record[childrenColumnName].length; i += 1) {
|
|
49296
|
-
fillRecords(list2, record[childrenColumnName][i], indent + 1, childrenColumnName, expandedKeys,
|
|
49296
|
+
fillRecords(list2, record[childrenColumnName][i], indent + 1, childrenColumnName, expandedKeys, getRowKey2, i);
|
|
49297
49297
|
}
|
|
49298
49298
|
}
|
|
49299
49299
|
}
|
|
49300
|
-
function useFlattenRecords(data, childrenColumnName, expandedKeys,
|
|
49300
|
+
function useFlattenRecords(data, childrenColumnName, expandedKeys, getRowKey2) {
|
|
49301
49301
|
var arr = React.useMemo(function() {
|
|
49302
49302
|
if (expandedKeys !== null && expandedKeys !== void 0 && expandedKeys.size) {
|
|
49303
49303
|
var list2 = [];
|
|
49304
49304
|
for (var i = 0; i < (data === null || data === void 0 ? void 0 : data.length); i += 1) {
|
|
49305
49305
|
var record = data[i];
|
|
49306
|
-
fillRecords(list2, record, 0, childrenColumnName, expandedKeys,
|
|
49306
|
+
fillRecords(list2, record, 0, childrenColumnName, expandedKeys, getRowKey2, i);
|
|
49307
49307
|
}
|
|
49308
49308
|
return list2;
|
|
49309
49309
|
}
|
|
@@ -49312,10 +49312,10 @@ function useFlattenRecords(data, childrenColumnName, expandedKeys, getRowKey) {
|
|
|
49312
49312
|
record: item,
|
|
49313
49313
|
indent: 0,
|
|
49314
49314
|
index: index2,
|
|
49315
|
-
rowKey:
|
|
49315
|
+
rowKey: getRowKey2(item, index2)
|
|
49316
49316
|
};
|
|
49317
49317
|
});
|
|
49318
|
-
}, [data, childrenColumnName, expandedKeys,
|
|
49318
|
+
}, [data, childrenColumnName, expandedKeys, getRowKey2]);
|
|
49319
49319
|
return arr;
|
|
49320
49320
|
}
|
|
49321
49321
|
function useRowInfo(record, rowKey, recordIndex, indent) {
|
|
@@ -49406,11 +49406,11 @@ function renderExpandIcon$1(_ref) {
|
|
|
49406
49406
|
onClick
|
|
49407
49407
|
});
|
|
49408
49408
|
}
|
|
49409
|
-
function findAllChildrenKeys(data,
|
|
49409
|
+
function findAllChildrenKeys(data, getRowKey2, childrenColumnName) {
|
|
49410
49410
|
var keys2 = [];
|
|
49411
49411
|
function dig(list2) {
|
|
49412
49412
|
(list2 || []).forEach(function(item, index2) {
|
|
49413
|
-
keys2.push(
|
|
49413
|
+
keys2.push(getRowKey2(item, index2));
|
|
49414
49414
|
dig(item[childrenColumnName]);
|
|
49415
49415
|
});
|
|
49416
49416
|
}
|
|
@@ -49585,8 +49585,8 @@ function Body(props) {
|
|
|
49585
49585
|
devRenderTimes(props);
|
|
49586
49586
|
}
|
|
49587
49587
|
var data = props.data, measureColumnWidth = props.measureColumnWidth;
|
|
49588
|
-
var _useContext = useContext(TableContext, ["prefixCls", "getComponent", "onColumnResize", "flattenColumns", "getRowKey", "expandedKeys", "childrenColumnName", "emptyNode", "expandedRowOffset", "fixedInfoList", "colWidths"]), prefixCls = _useContext.prefixCls, getComponent = _useContext.getComponent, onColumnResize = _useContext.onColumnResize, flattenColumns = _useContext.flattenColumns,
|
|
49589
|
-
var flattenData2 = useFlattenRecords(data, childrenColumnName, expandedKeys,
|
|
49588
|
+
var _useContext = useContext(TableContext, ["prefixCls", "getComponent", "onColumnResize", "flattenColumns", "getRowKey", "expandedKeys", "childrenColumnName", "emptyNode", "expandedRowOffset", "fixedInfoList", "colWidths"]), prefixCls = _useContext.prefixCls, getComponent = _useContext.getComponent, onColumnResize = _useContext.onColumnResize, flattenColumns = _useContext.flattenColumns, getRowKey2 = _useContext.getRowKey, expandedKeys = _useContext.expandedKeys, childrenColumnName = _useContext.childrenColumnName, emptyNode = _useContext.emptyNode, _useContext$expandedR = _useContext.expandedRowOffset, expandedRowOffset = _useContext$expandedR === void 0 ? 0 : _useContext$expandedR, colWidths = _useContext.colWidths;
|
|
49589
|
+
var flattenData2 = useFlattenRecords(data, childrenColumnName, expandedKeys, getRowKey2);
|
|
49590
49590
|
var rowKeys = React.useMemo(function() {
|
|
49591
49591
|
return flattenData2.map(function(item) {
|
|
49592
49592
|
return item.rowKey;
|
|
@@ -50055,7 +50055,7 @@ function revertForRtl(columns) {
|
|
|
50055
50055
|
});
|
|
50056
50056
|
}
|
|
50057
50057
|
function useColumns(_ref2, transformColumns) {
|
|
50058
|
-
var prefixCls = _ref2.prefixCls, columns = _ref2.columns, children2 = _ref2.children, expandable = _ref2.expandable, expandedKeys = _ref2.expandedKeys, columnTitle = _ref2.columnTitle,
|
|
50058
|
+
var prefixCls = _ref2.prefixCls, columns = _ref2.columns, children2 = _ref2.children, expandable = _ref2.expandable, expandedKeys = _ref2.expandedKeys, columnTitle = _ref2.columnTitle, getRowKey2 = _ref2.getRowKey, onTriggerExpand = _ref2.onTriggerExpand, expandIcon = _ref2.expandIcon, rowExpandable = _ref2.rowExpandable, expandIconColumnIndex = _ref2.expandIconColumnIndex, _ref2$expandedRowOffs = _ref2.expandedRowOffset, expandedRowOffset = _ref2$expandedRowOffs === void 0 ? 0 : _ref2$expandedRowOffs, direction = _ref2.direction, expandRowByClick = _ref2.expandRowByClick, columnWidth = _ref2.columnWidth, fixed = _ref2.fixed, scrollWidth = _ref2.scrollWidth, clientWidth = _ref2.clientWidth;
|
|
50059
50059
|
var baseColumns = React.useMemo(function() {
|
|
50060
50060
|
var newColumns = columns || convertChildrenToColumns(children2) || [];
|
|
50061
50061
|
return filterHiddenColumns(newColumns.slice());
|
|
@@ -50095,7 +50095,7 @@ function useColumns(_ref2, transformColumns) {
|
|
|
50095
50095
|
className: "".concat(prefixCls, "-expand-icon-col"),
|
|
50096
50096
|
columnType: "EXPAND_COLUMN"
|
|
50097
50097
|
}), "title", columnTitle), "fixed", fixedColumn), "className", "".concat(prefixCls, "-row-expand-icon-cell")), "width", columnWidth), "render", function render2(_, record, index2) {
|
|
50098
|
-
var rowKey =
|
|
50098
|
+
var rowKey = getRowKey2(record, index2);
|
|
50099
50099
|
var expanded = expandedKeys.has(rowKey);
|
|
50100
50100
|
var recordExpandable = rowExpandable ? rowExpandable(record) : true;
|
|
50101
50101
|
var icon = expandIcon({
|
|
@@ -50130,7 +50130,7 @@ function useColumns(_ref2, transformColumns) {
|
|
|
50130
50130
|
return baseColumns.filter(function(col) {
|
|
50131
50131
|
return col !== EXPAND_COLUMN;
|
|
50132
50132
|
});
|
|
50133
|
-
}, [expandable, baseColumns,
|
|
50133
|
+
}, [expandable, baseColumns, getRowKey2, expandedKeys, expandIcon, direction, expandedRowOffset]);
|
|
50134
50134
|
var mergedColumns = React.useMemo(function() {
|
|
50135
50135
|
var finalColumns = withExpandColumns;
|
|
50136
50136
|
if (transformColumns) {
|
|
@@ -50185,7 +50185,7 @@ function useColumns(_ref2, transformColumns) {
|
|
|
50185
50185
|
var _useWidthColumns = useWidthColumns(flattenColumns, scrollWidth, clientWidth), _useWidthColumns2 = _slicedToArray(_useWidthColumns, 2), filledColumns = _useWidthColumns2[0], realScrollWidth = _useWidthColumns2[1];
|
|
50186
50186
|
return [mergedColumns, filledColumns, realScrollWidth, hasGapFixed];
|
|
50187
50187
|
}
|
|
50188
|
-
function useExpand(props, mergedData,
|
|
50188
|
+
function useExpand(props, mergedData, getRowKey2) {
|
|
50189
50189
|
var expandableConfig = getExpandableProps(props);
|
|
50190
50190
|
var expandIcon = expandableConfig.expandIcon, expandedRowKeys = expandableConfig.expandedRowKeys, defaultExpandedRowKeys = expandableConfig.defaultExpandedRowKeys, defaultExpandAllRows = expandableConfig.defaultExpandAllRows, expandedRowRender = expandableConfig.expandedRowRender, onExpand = expandableConfig.onExpand, onExpandedRowsChange = expandableConfig.onExpandedRowsChange, childrenColumnName = expandableConfig.childrenColumnName;
|
|
50191
50191
|
var mergedExpandIcon = expandIcon || renderExpandIcon$1;
|
|
@@ -50206,7 +50206,7 @@ function useExpand(props, mergedData, getRowKey) {
|
|
|
50206
50206
|
return defaultExpandedRowKeys;
|
|
50207
50207
|
}
|
|
50208
50208
|
if (defaultExpandAllRows) {
|
|
50209
|
-
return findAllChildrenKeys(mergedData,
|
|
50209
|
+
return findAllChildrenKeys(mergedData, getRowKey2, mergedChildrenColumnName);
|
|
50210
50210
|
}
|
|
50211
50211
|
return [];
|
|
50212
50212
|
}), _React$useState2 = _slicedToArray(_React$useState, 2), innerExpandedKeys = _React$useState2[0], setInnerExpandedKeys = _React$useState2[1];
|
|
@@ -50214,7 +50214,7 @@ function useExpand(props, mergedData, getRowKey) {
|
|
|
50214
50214
|
return new Set(expandedRowKeys || innerExpandedKeys || []);
|
|
50215
50215
|
}, [expandedRowKeys, innerExpandedKeys]);
|
|
50216
50216
|
var onTriggerExpand = React.useCallback(function(record) {
|
|
50217
|
-
var key =
|
|
50217
|
+
var key = getRowKey2(record, mergedData.indexOf(record));
|
|
50218
50218
|
var newExpandedKeys;
|
|
50219
50219
|
var hasKey = mergedExpandedKeys.has(key);
|
|
50220
50220
|
if (hasKey) {
|
|
@@ -50230,7 +50230,7 @@ function useExpand(props, mergedData, getRowKey) {
|
|
|
50230
50230
|
if (onExpandedRowsChange) {
|
|
50231
50231
|
onExpandedRowsChange(newExpandedKeys);
|
|
50232
50232
|
}
|
|
50233
|
-
}, [
|
|
50233
|
+
}, [getRowKey2, mergedExpandedKeys, mergedData, onExpand, onExpandedRowsChange]);
|
|
50234
50234
|
if (process.env.NODE_ENV !== "production" && expandedRowRender && mergedData.some(function(record) {
|
|
50235
50235
|
return Array.isArray(record === null || record === void 0 ? void 0 : record[mergedChildrenColumnName]);
|
|
50236
50236
|
})) {
|
|
@@ -50550,7 +50550,7 @@ function Table$3(tableProps, ref) {
|
|
|
50550
50550
|
var getComponent = React.useCallback(function(path2, defaultComponent) {
|
|
50551
50551
|
return get$2(components2, path2) || defaultComponent;
|
|
50552
50552
|
}, [components2]);
|
|
50553
|
-
var
|
|
50553
|
+
var getRowKey2 = React.useMemo(function() {
|
|
50554
50554
|
if (typeof rowKey === "function") {
|
|
50555
50555
|
return rowKey;
|
|
50556
50556
|
}
|
|
@@ -50564,14 +50564,14 @@ function Table$3(tableProps, ref) {
|
|
|
50564
50564
|
}, [rowKey]);
|
|
50565
50565
|
var customizeScrollBody = getComponent(["body"]);
|
|
50566
50566
|
var _useHover = useHover(), _useHover2 = _slicedToArray(_useHover, 3), startRow = _useHover2[0], endRow = _useHover2[1], onHover = _useHover2[2];
|
|
50567
|
-
var _useExpand = useExpand(props, mergedData,
|
|
50567
|
+
var _useExpand = useExpand(props, mergedData, getRowKey2), _useExpand2 = _slicedToArray(_useExpand, 6), expandableConfig = _useExpand2[0], expandableType = _useExpand2[1], mergedExpandedKeys = _useExpand2[2], mergedExpandIcon = _useExpand2[3], mergedChildrenColumnName = _useExpand2[4], onTriggerExpand = _useExpand2[5];
|
|
50568
50568
|
var scrollX = scroll === null || scroll === void 0 ? void 0 : scroll.x;
|
|
50569
50569
|
var _React$useState = React.useState(0), _React$useState2 = _slicedToArray(_React$useState, 2), componentWidth = _React$useState2[0], setComponentWidth = _React$useState2[1];
|
|
50570
50570
|
var _useColumns = useColumns(_objectSpread2(_objectSpread2(_objectSpread2({}, props), expandableConfig), {}, {
|
|
50571
50571
|
expandable: !!expandableConfig.expandedRowRender,
|
|
50572
50572
|
columnTitle: expandableConfig.columnTitle,
|
|
50573
50573
|
expandedKeys: mergedExpandedKeys,
|
|
50574
|
-
getRowKey,
|
|
50574
|
+
getRowKey: getRowKey2,
|
|
50575
50575
|
// https://github.com/ant-design/ant-design/issues/23894
|
|
50576
50576
|
onTriggerExpand,
|
|
50577
50577
|
expandIcon: mergedExpandIcon,
|
|
@@ -50605,7 +50605,7 @@ function Table$3(tableProps, ref) {
|
|
|
50605
50605
|
});
|
|
50606
50606
|
} else {
|
|
50607
50607
|
var _scrollBodyRef$curren2;
|
|
50608
|
-
var mergedKey = key !== null && key !== void 0 ? key :
|
|
50608
|
+
var mergedKey = key !== null && key !== void 0 ? key : getRowKey2(mergedData[index2]);
|
|
50609
50609
|
(_scrollBodyRef$curren2 = scrollBodyRef.current.querySelector('[data-row-key="'.concat(mergedKey, '"]'))) === null || _scrollBodyRef$curren2 === void 0 || _scrollBodyRef$curren2.scrollIntoView();
|
|
50610
50610
|
}
|
|
50611
50611
|
} else if ((_scrollBodyRef$curren3 = scrollBodyRef.current) !== null && _scrollBodyRef$curren3 !== void 0 && _scrollBodyRef$curren3.scrollTo) {
|
|
@@ -50971,7 +50971,7 @@ function Table$3(tableProps, ref) {
|
|
|
50971
50971
|
onHover,
|
|
50972
50972
|
rowExpandable: expandableConfig.rowExpandable,
|
|
50973
50973
|
onRow,
|
|
50974
|
-
getRowKey,
|
|
50974
|
+
getRowKey: getRowKey2,
|
|
50975
50975
|
expandedKeys: mergedExpandedKeys,
|
|
50976
50976
|
childrenColumnName: mergedChildrenColumnName,
|
|
50977
50977
|
rowHoverable
|
|
@@ -51015,7 +51015,7 @@ function Table$3(tableProps, ref) {
|
|
|
51015
51015
|
onHover,
|
|
51016
51016
|
expandableConfig.rowExpandable,
|
|
51017
51017
|
onRow,
|
|
51018
|
-
|
|
51018
|
+
getRowKey2,
|
|
51019
51019
|
mergedExpandedKeys,
|
|
51020
51020
|
mergedChildrenColumnName,
|
|
51021
51021
|
rowHoverable
|
|
@@ -51169,10 +51169,10 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
51169
51169
|
}
|
|
51170
51170
|
var Grid = /* @__PURE__ */ React.forwardRef(function(props, ref) {
|
|
51171
51171
|
var data = props.data, onScroll = props.onScroll;
|
|
51172
|
-
var _useContext = useContext(TableContext, ["flattenColumns", "onColumnResize", "getRowKey", "prefixCls", "expandedKeys", "childrenColumnName", "scrollX", "direction"]), flattenColumns = _useContext.flattenColumns, onColumnResize = _useContext.onColumnResize,
|
|
51172
|
+
var _useContext = useContext(TableContext, ["flattenColumns", "onColumnResize", "getRowKey", "prefixCls", "expandedKeys", "childrenColumnName", "scrollX", "direction"]), flattenColumns = _useContext.flattenColumns, onColumnResize = _useContext.onColumnResize, getRowKey2 = _useContext.getRowKey, expandedKeys = _useContext.expandedKeys, prefixCls = _useContext.prefixCls, childrenColumnName = _useContext.childrenColumnName, scrollX = _useContext.scrollX, direction = _useContext.direction;
|
|
51173
51173
|
var _useContext2 = useContext(StaticContext), sticky = _useContext2.sticky, scrollY = _useContext2.scrollY, listItemHeight = _useContext2.listItemHeight, getComponent = _useContext2.getComponent, onTablePropScroll = _useContext2.onScroll;
|
|
51174
51174
|
var listRef = React.useRef();
|
|
51175
|
-
var flattenData2 = useFlattenRecords(data, childrenColumnName, expandedKeys,
|
|
51175
|
+
var flattenData2 = useFlattenRecords(data, childrenColumnName, expandedKeys, getRowKey2);
|
|
51176
51176
|
var columnsWidth = React.useMemo(function() {
|
|
51177
51177
|
var total = 0;
|
|
51178
51178
|
return flattenColumns.map(function(_ref) {
|
|
@@ -51286,10 +51286,10 @@ var Grid = /* @__PURE__ */ React.forwardRef(function(props, ref) {
|
|
|
51286
51286
|
}
|
|
51287
51287
|
var nodes = spanLines.map(function(index2) {
|
|
51288
51288
|
var item = flattenData2[index2];
|
|
51289
|
-
var rowKey =
|
|
51289
|
+
var rowKey = getRowKey2(item.record, index2);
|
|
51290
51290
|
var getHeight2 = function getHeight3(rowSpan) {
|
|
51291
51291
|
var endItemIndex = index2 + rowSpan - 1;
|
|
51292
|
-
var endItemKey =
|
|
51292
|
+
var endItemKey = getRowKey2(flattenData2[endItemIndex].record, endItemIndex);
|
|
51293
51293
|
var sizeInfo2 = getSize3(rowKey, endItemKey);
|
|
51294
51294
|
return sizeInfo2.bottom - sizeInfo2.top;
|
|
51295
51295
|
};
|
|
@@ -51337,7 +51337,7 @@ var Grid = /* @__PURE__ */ React.forwardRef(function(props, ref) {
|
|
|
51337
51337
|
itemHeight: listItemHeight || 24,
|
|
51338
51338
|
data: flattenData2,
|
|
51339
51339
|
itemKey: function itemKey2(item) {
|
|
51340
|
-
return
|
|
51340
|
+
return getRowKey2(item.record);
|
|
51341
51341
|
},
|
|
51342
51342
|
component: wrapperComponent,
|
|
51343
51343
|
scrollWidth: scrollX,
|
|
@@ -51353,7 +51353,7 @@ var Grid = /* @__PURE__ */ React.forwardRef(function(props, ref) {
|
|
|
51353
51353
|
onScroll: onTablePropScroll,
|
|
51354
51354
|
extraRender
|
|
51355
51355
|
}, function(item, index2, itemProps) {
|
|
51356
|
-
var rowKey =
|
|
51356
|
+
var rowKey = getRowKey2(item.record, index2);
|
|
51357
51357
|
return /* @__PURE__ */ React.createElement(ResponseBodyLine, {
|
|
51358
51358
|
data: item,
|
|
51359
51359
|
rowKey,
|
|
@@ -51970,7 +51970,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
51970
51970
|
data,
|
|
51971
51971
|
pageData,
|
|
51972
51972
|
getRecordByKey,
|
|
51973
|
-
getRowKey,
|
|
51973
|
+
getRowKey: getRowKey2,
|
|
51974
51974
|
expandType,
|
|
51975
51975
|
childrenColumnName,
|
|
51976
51976
|
locale: tableLocale,
|
|
@@ -52009,35 +52009,35 @@ const useSelection = (config, rowSelection) => {
|
|
|
52009
52009
|
}
|
|
52010
52010
|
let convertData = data;
|
|
52011
52011
|
if (preserveSelectedRowKeys) {
|
|
52012
|
-
const keysSet = new Set(flattedData.map((record, index2) =>
|
|
52012
|
+
const keysSet = new Set(flattedData.map((record, index2) => getRowKey2(record, index2)));
|
|
52013
52013
|
const preserveRecords = Array.from(preserveRecordsRef.current).reduce((total, [key, value2]) => keysSet.has(key) ? total : total.concat(value2), []);
|
|
52014
52014
|
convertData = [].concat(_toConsumableArray(convertData), _toConsumableArray(preserveRecords));
|
|
52015
52015
|
}
|
|
52016
52016
|
return convertDataToEntities(convertData, {
|
|
52017
|
-
externalGetKey:
|
|
52017
|
+
externalGetKey: getRowKey2,
|
|
52018
52018
|
childrenPropName: childrenColumnName
|
|
52019
52019
|
});
|
|
52020
|
-
}, [data,
|
|
52020
|
+
}, [data, getRowKey2, checkStrictly, childrenColumnName, preserveSelectedRowKeys, flattedData]);
|
|
52021
52021
|
const checkboxPropsMap = useMemo$1(() => {
|
|
52022
52022
|
const map2 = /* @__PURE__ */ new Map();
|
|
52023
52023
|
flattedData.forEach((record, index2) => {
|
|
52024
|
-
const key =
|
|
52024
|
+
const key = getRowKey2(record, index2);
|
|
52025
52025
|
const checkboxProps = (getCheckboxProps ? getCheckboxProps(record) : null) || {};
|
|
52026
52026
|
map2.set(key, checkboxProps);
|
|
52027
52027
|
process.env.NODE_ENV !== "production" ? warning3(!("checked" in checkboxProps || "defaultChecked" in checkboxProps), "usage", "Do not set `checked` or `defaultChecked` in `getCheckboxProps`. Please use `selectedRowKeys` instead.") : void 0;
|
|
52028
52028
|
});
|
|
52029
52029
|
return map2;
|
|
52030
|
-
}, [flattedData,
|
|
52030
|
+
}, [flattedData, getRowKey2, getCheckboxProps]);
|
|
52031
52031
|
const isCheckboxDisabled = useCallback((r2) => {
|
|
52032
|
-
const rowKey =
|
|
52032
|
+
const rowKey = getRowKey2(r2);
|
|
52033
52033
|
let checkboxProps;
|
|
52034
52034
|
if (checkboxPropsMap.has(rowKey)) {
|
|
52035
|
-
checkboxProps = checkboxPropsMap.get(
|
|
52035
|
+
checkboxProps = checkboxPropsMap.get(getRowKey2(r2));
|
|
52036
52036
|
} else {
|
|
52037
52037
|
checkboxProps = getCheckboxProps ? getCheckboxProps(r2) : void 0;
|
|
52038
52038
|
}
|
|
52039
52039
|
return !!(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.disabled);
|
|
52040
|
-
}, [checkboxPropsMap,
|
|
52040
|
+
}, [checkboxPropsMap, getRowKey2]);
|
|
52041
52041
|
const [derivedSelectedKeys, derivedHalfSelectedKeys] = useMemo$1(() => {
|
|
52042
52042
|
if (checkStrictly) {
|
|
52043
52043
|
return [mergedSelectedKeys || [], []];
|
|
@@ -52099,7 +52099,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52099
52099
|
key: "all",
|
|
52100
52100
|
text: tableLocale.selectionAll,
|
|
52101
52101
|
onSelect() {
|
|
52102
|
-
setSelectedKeys(data.map((record, index2) =>
|
|
52102
|
+
setSelectedKeys(data.map((record, index2) => getRowKey2(record, index2)).filter((key) => {
|
|
52103
52103
|
const checkProps = checkboxPropsMap.get(key);
|
|
52104
52104
|
return !(checkProps === null || checkProps === void 0 ? void 0 : checkProps.disabled) || derivedSelectedKeySet.has(key);
|
|
52105
52105
|
}), "all");
|
|
@@ -52113,7 +52113,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52113
52113
|
onSelect() {
|
|
52114
52114
|
const keySet = new Set(derivedSelectedKeySet);
|
|
52115
52115
|
pageData.forEach((record, index2) => {
|
|
52116
|
-
const key =
|
|
52116
|
+
const key = getRowKey2(record, index2);
|
|
52117
52117
|
const checkProps = checkboxPropsMap.get(key);
|
|
52118
52118
|
if (!(checkProps === null || checkProps === void 0 ? void 0 : checkProps.disabled)) {
|
|
52119
52119
|
if (keySet.has(key)) {
|
|
@@ -52154,7 +52154,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52154
52154
|
updatePrevSelectedIndex(null);
|
|
52155
52155
|
}
|
|
52156
52156
|
}));
|
|
52157
|
-
}, [selections, derivedSelectedKeySet, pageData,
|
|
52157
|
+
}, [selections, derivedSelectedKeySet, pageData, getRowKey2, onSelectInvert, setSelectedKeys]);
|
|
52158
52158
|
const transformColumns = useCallback((columns) => {
|
|
52159
52159
|
var _a;
|
|
52160
52160
|
if (!rowSelection) {
|
|
@@ -52163,7 +52163,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52163
52163
|
}
|
|
52164
52164
|
let cloneColumns = _toConsumableArray(columns);
|
|
52165
52165
|
const keySet = new Set(derivedSelectedKeySet);
|
|
52166
|
-
const recordKeys = flattedData.map(
|
|
52166
|
+
const recordKeys = flattedData.map(getRowKey2).filter((key) => !checkboxPropsMap.get(key).disabled);
|
|
52167
52167
|
const checkedCurrentAll = recordKeys.every((key) => keySet.has(key));
|
|
52168
52168
|
const checkedCurrentSome = recordKeys.some((key) => keySet.has(key));
|
|
52169
52169
|
const onSelectAllChange = () => {
|
|
@@ -52216,7 +52216,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52216
52216
|
}, /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(RefIcon$w, null))));
|
|
52217
52217
|
}
|
|
52218
52218
|
const allDisabledData = flattedData.map((record, index2) => {
|
|
52219
|
-
const key =
|
|
52219
|
+
const key = getRowKey2(record, index2);
|
|
52220
52220
|
const checkboxProps = checkboxPropsMap.get(key) || {};
|
|
52221
52221
|
return Object.assign({
|
|
52222
52222
|
checked: keySet.has(key)
|
|
@@ -52255,7 +52255,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52255
52255
|
let renderCell;
|
|
52256
52256
|
if (selectionType === "radio") {
|
|
52257
52257
|
renderCell = (_, record, index2) => {
|
|
52258
|
-
const key =
|
|
52258
|
+
const key = getRowKey2(record, index2);
|
|
52259
52259
|
const checked = keySet.has(key);
|
|
52260
52260
|
const checkboxProps = checkboxPropsMap.get(key);
|
|
52261
52261
|
return {
|
|
@@ -52280,7 +52280,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52280
52280
|
} else {
|
|
52281
52281
|
renderCell = (_, record, index2) => {
|
|
52282
52282
|
var _a2;
|
|
52283
|
-
const key =
|
|
52283
|
+
const key = getRowKey2(record, index2);
|
|
52284
52284
|
const checked = keySet.has(key);
|
|
52285
52285
|
const indeterminate = derivedHalfSelectedKeySet.has(key);
|
|
52286
52286
|
const checkboxProps = checkboxPropsMap.get(key);
|
|
@@ -52412,7 +52412,7 @@ const useSelection = (config, rowSelection) => {
|
|
|
52412
52412
|
}
|
|
52413
52413
|
};
|
|
52414
52414
|
return cloneColumns.map((col) => col === SELECTION_COLUMN ? selectionColumn : col);
|
|
52415
|
-
}, [
|
|
52415
|
+
}, [getRowKey2, flattedData, rowSelection, derivedSelectedKeys, derivedSelectedKeySet, derivedHalfSelectedKeySet, selectionColWidth, mergedSelections, expandType, checkboxPropsMap, onSelectMultiple, triggerSingleSelection, isCheckboxDisabled]);
|
|
52416
52416
|
return [transformColumns, derivedSelectedKeySet];
|
|
52417
52417
|
};
|
|
52418
52418
|
function fillProxy(element2, handler) {
|
|
@@ -55292,14 +55292,14 @@ const useFilter = (props) => {
|
|
|
55292
55292
|
const transformColumns = (innerColumns) => injectFilter(prefixCls, dropdownPrefixCls, innerColumns, mergedFilterStates, tableLocale, triggerFilter, getPopupContainer, void 0, rootClassName);
|
|
55293
55293
|
return [transformColumns, mergedFilterStates, filters];
|
|
55294
55294
|
};
|
|
55295
|
-
const useLazyKVMap = (data, childrenColumnName,
|
|
55295
|
+
const useLazyKVMap = (data, childrenColumnName, getRowKey2) => {
|
|
55296
55296
|
const mapCacheRef = React.useRef({});
|
|
55297
55297
|
function getRecordByKey(key) {
|
|
55298
55298
|
var _a;
|
|
55299
|
-
if (!mapCacheRef.current || mapCacheRef.current.data !== data || mapCacheRef.current.childrenColumnName !== childrenColumnName || mapCacheRef.current.getRowKey !==
|
|
55299
|
+
if (!mapCacheRef.current || mapCacheRef.current.data !== data || mapCacheRef.current.childrenColumnName !== childrenColumnName || mapCacheRef.current.getRowKey !== getRowKey2) {
|
|
55300
55300
|
let dig = function(records) {
|
|
55301
55301
|
records.forEach((record, index2) => {
|
|
55302
|
-
const rowKey =
|
|
55302
|
+
const rowKey = getRowKey2(record, index2);
|
|
55303
55303
|
kvMap.set(rowKey, record);
|
|
55304
55304
|
if (record && typeof record === "object" && childrenColumnName in record) {
|
|
55305
55305
|
dig(record[childrenColumnName] || []);
|
|
@@ -55312,7 +55312,7 @@ const useLazyKVMap = (data, childrenColumnName, getRowKey) => {
|
|
|
55312
55312
|
data,
|
|
55313
55313
|
childrenColumnName,
|
|
55314
55314
|
kvMap,
|
|
55315
|
-
getRowKey
|
|
55315
|
+
getRowKey: getRowKey2
|
|
55316
55316
|
};
|
|
55317
55317
|
}
|
|
55318
55318
|
return (_a = mapCacheRef.current.kvMap) === null || _a === void 0 ? void 0 : _a.get(key);
|
|
@@ -57220,13 +57220,13 @@ const InternalTable = (props, ref) => {
|
|
|
57220
57220
|
useProxyImperativeHandle(ref, () => Object.assign(Object.assign({}, tblRef.current), {
|
|
57221
57221
|
nativeElement: rootRef.current
|
|
57222
57222
|
}));
|
|
57223
|
-
const
|
|
57223
|
+
const getRowKey2 = React.useMemo(() => {
|
|
57224
57224
|
if (typeof rowKey === "function") {
|
|
57225
57225
|
return rowKey;
|
|
57226
57226
|
}
|
|
57227
57227
|
return (record) => record === null || record === void 0 ? void 0 : record[rowKey];
|
|
57228
57228
|
}, [rowKey]);
|
|
57229
|
-
const [getRecordByKey] = useLazyKVMap(rawData, childrenColumnName,
|
|
57229
|
+
const [getRecordByKey] = useLazyKVMap(rawData, childrenColumnName, getRowKey2);
|
|
57230
57230
|
const changeEventInfo = {};
|
|
57231
57231
|
const triggerOnChange = (info, action, reset = false) => {
|
|
57232
57232
|
var _a2, _b2, _c, _d;
|
|
@@ -57331,7 +57331,7 @@ const InternalTable = (props, ref) => {
|
|
|
57331
57331
|
prefixCls,
|
|
57332
57332
|
data: mergedData,
|
|
57333
57333
|
pageData,
|
|
57334
|
-
getRowKey,
|
|
57334
|
+
getRowKey: getRowKey2,
|
|
57335
57335
|
getRecordByKey,
|
|
57336
57336
|
expandType,
|
|
57337
57337
|
childrenColumnName,
|
|
@@ -57346,7 +57346,7 @@ const InternalTable = (props, ref) => {
|
|
|
57346
57346
|
mergedRowClassName = classNames(rowClassName);
|
|
57347
57347
|
}
|
|
57348
57348
|
return classNames({
|
|
57349
|
-
[`${prefixCls}-row-selected`]: selectedKeySet.has(
|
|
57349
|
+
[`${prefixCls}-row-selected`]: selectedKeySet.has(getRowKey2(record, index2))
|
|
57350
57350
|
}, mergedRowClassName);
|
|
57351
57351
|
};
|
|
57352
57352
|
mergedExpandable.__PARENT_RENDER_ICON__ = mergedExpandable.expandIcon;
|
|
@@ -57454,7 +57454,7 @@ const InternalTable = (props, ref) => {
|
|
|
57454
57454
|
[`${prefixCls}-empty`]: rawData.length === 0
|
|
57455
57455
|
}, cssVarCls, rootCls, hashId),
|
|
57456
57456
|
data: pageData,
|
|
57457
|
-
rowKey:
|
|
57457
|
+
rowKey: getRowKey2,
|
|
57458
57458
|
rowClassName: internalRowClassName,
|
|
57459
57459
|
emptyText,
|
|
57460
57460
|
// Internal
|
|
@@ -83958,6 +83958,39 @@ function requireDebounce() {
|
|
|
83958
83958
|
}
|
|
83959
83959
|
var debounceExports = /* @__PURE__ */ requireDebounce();
|
|
83960
83960
|
const debounce = /* @__PURE__ */ getDefaultExportFromCjs(debounceExports);
|
|
83961
|
+
const getRowKey = (record, rowKey, index2, enableValidation = true) => {
|
|
83962
|
+
try {
|
|
83963
|
+
const key = typeof rowKey === "function" ? rowKey(record) : record[rowKey];
|
|
83964
|
+
if (enableValidation) {
|
|
83965
|
+
if (key === void 0 || key === null) {
|
|
83966
|
+
console.error(`Genesis Table: rowKey "${String(rowKey)}" returned undefined/null for record at index ${index2}.`, {
|
|
83967
|
+
record,
|
|
83968
|
+
rowKey,
|
|
83969
|
+
availableKeys: Object.keys(record)
|
|
83970
|
+
});
|
|
83971
|
+
return `fallback-${index2}`;
|
|
83972
|
+
}
|
|
83973
|
+
if (typeof key === "string" && String(key).trim() === "") {
|
|
83974
|
+
console.warn(`Genesis Table: rowKey "${String(rowKey)}" returned empty string for record at index ${index2}.`, {
|
|
83975
|
+
record,
|
|
83976
|
+
rowKey
|
|
83977
|
+
});
|
|
83978
|
+
return `fallback-${index2}`;
|
|
83979
|
+
}
|
|
83980
|
+
}
|
|
83981
|
+
return key;
|
|
83982
|
+
} catch (error2) {
|
|
83983
|
+
if (enableValidation) {
|
|
83984
|
+
console.error(`Genesis Table: Error accessing rowKey "${String(rowKey)}" for record at index ${index2}.`, {
|
|
83985
|
+
error: error2,
|
|
83986
|
+
record,
|
|
83987
|
+
rowKey,
|
|
83988
|
+
availableKeys: Object.keys(record)
|
|
83989
|
+
});
|
|
83990
|
+
}
|
|
83991
|
+
return `fallback-${index2}`;
|
|
83992
|
+
}
|
|
83993
|
+
};
|
|
83961
83994
|
function Table({
|
|
83962
83995
|
columns,
|
|
83963
83996
|
dataSource,
|
|
@@ -83970,6 +84003,8 @@ function Table({
|
|
|
83970
84003
|
isMainContentCell = false,
|
|
83971
84004
|
isMaterializedView = false,
|
|
83972
84005
|
materializedViewConfig,
|
|
84006
|
+
enableRowKeyValidation = process.env.NODE_ENV === "development",
|
|
84007
|
+
onRowKeyError,
|
|
83973
84008
|
...rest
|
|
83974
84009
|
}) {
|
|
83975
84010
|
const [materializedData, setMaterializedData] = React.useState([]);
|
|
@@ -84084,6 +84119,42 @@ function Table({
|
|
|
84084
84119
|
return rest.scroll;
|
|
84085
84120
|
}, [isMaterializedView, materializedViewConfig, dynamicHeight, rest.scroll]);
|
|
84086
84121
|
const tableDataSource = isMaterializedView ? materializedData : dataSource;
|
|
84122
|
+
React.useEffect(() => {
|
|
84123
|
+
if (enableRowKeyValidation && tableDataSource.length > 0) {
|
|
84124
|
+
const sampleRecord = tableDataSource[0];
|
|
84125
|
+
if (typeof rowKey === "string") {
|
|
84126
|
+
if (!(rowKey in sampleRecord)) {
|
|
84127
|
+
const error2 = new Error(`rowKey "${rowKey}" does not exist in data records`);
|
|
84128
|
+
console.error(`Genesis Table: ${error2.message}. Available keys:`, Object.keys(sampleRecord));
|
|
84129
|
+
onRowKeyError?.({
|
|
84130
|
+
record: sampleRecord,
|
|
84131
|
+
rowKey,
|
|
84132
|
+
index: 0,
|
|
84133
|
+
error: error2
|
|
84134
|
+
});
|
|
84135
|
+
}
|
|
84136
|
+
}
|
|
84137
|
+
const keys2 = tableDataSource.map(
|
|
84138
|
+
(record, index2) => getRowKey(record, rowKey, index2, false)
|
|
84139
|
+
// Don't log individual errors here
|
|
84140
|
+
);
|
|
84141
|
+
const uniqueKeys = [...new Set(keys2)];
|
|
84142
|
+
if (keys2.length !== uniqueKeys.length) {
|
|
84143
|
+
const error2 = new Error(`Duplicate row keys detected`);
|
|
84144
|
+
console.error(`Genesis Table: ${error2.message}!`, {
|
|
84145
|
+
totalKeys: keys2.length,
|
|
84146
|
+
uniqueKeys: uniqueKeys.length,
|
|
84147
|
+
duplicates: keys2.filter((key, index2) => keys2.indexOf(key) !== index2)
|
|
84148
|
+
});
|
|
84149
|
+
onRowKeyError?.({
|
|
84150
|
+
record: tableDataSource[0],
|
|
84151
|
+
rowKey,
|
|
84152
|
+
index: 0,
|
|
84153
|
+
error: error2
|
|
84154
|
+
});
|
|
84155
|
+
}
|
|
84156
|
+
}
|
|
84157
|
+
}, [tableDataSource, rowKey, enableRowKeyValidation, onRowKeyError]);
|
|
84087
84158
|
const handleRowMouseDown = React.useCallback(
|
|
84088
84159
|
(record, index2, event) => {
|
|
84089
84160
|
const target = event.target;
|
|
@@ -84093,10 +84164,10 @@ function Table({
|
|
|
84093
84164
|
if (isInteractiveElement) {
|
|
84094
84165
|
return;
|
|
84095
84166
|
}
|
|
84096
|
-
const recordKey =
|
|
84167
|
+
const recordKey = getRowKey(record, rowKey, index2, enableRowKeyValidation);
|
|
84097
84168
|
setPressedRowKey(recordKey);
|
|
84098
84169
|
},
|
|
84099
|
-
[rowKey]
|
|
84170
|
+
[rowKey, enableRowKeyValidation]
|
|
84100
84171
|
);
|
|
84101
84172
|
const handleRowMouseUp = React.useCallback(
|
|
84102
84173
|
(record, index2, event) => {
|
|
@@ -84106,14 +84177,11 @@ function Table({
|
|
|
84106
84177
|
);
|
|
84107
84178
|
const handleRowClick = React.useCallback(
|
|
84108
84179
|
(record, index2, event) => {
|
|
84109
|
-
console.log("Row clicked:", record, "index:", index2);
|
|
84110
84180
|
const target = event.target;
|
|
84111
84181
|
const isInteractiveElement = target.closest(
|
|
84112
84182
|
'button, a, input, select, textarea, [role="button"], [onclick], .ant-checkbox-wrapper, .ant-checkbox'
|
|
84113
84183
|
);
|
|
84114
|
-
console.log("Is interactive element:", isInteractiveElement);
|
|
84115
84184
|
if (isInteractiveElement) {
|
|
84116
|
-
console.log("Skipping row click due to interactive element");
|
|
84117
84185
|
return;
|
|
84118
84186
|
}
|
|
84119
84187
|
if (onRowClick) {
|
|
@@ -84130,7 +84198,6 @@ function Table({
|
|
|
84130
84198
|
// Use internal state
|
|
84131
84199
|
// Override the onChange to ensure we get the latest data
|
|
84132
84200
|
onChange: (selectedRowKeys2, selectedRows) => {
|
|
84133
|
-
console.log("Row selection changed:", selectedRowKeys2, selectedRows);
|
|
84134
84201
|
setSelectedRowKeys(selectedRowKeys2);
|
|
84135
84202
|
if (rowSelection.onChange) {
|
|
84136
84203
|
rowSelection.onChange(selectedRowKeys2, selectedRows);
|
|
@@ -84152,7 +84219,7 @@ function Table({
|
|
|
84152
84219
|
rowSelection: enhancedRowSelection,
|
|
84153
84220
|
onRow: (record, index2) => {
|
|
84154
84221
|
const isDisabled = rowSelection?.getCheckboxProps?.(record)?.disabled ?? false;
|
|
84155
|
-
const recordKey =
|
|
84222
|
+
const recordKey = getRowKey(record, rowKey, index2 ?? 0, enableRowKeyValidation);
|
|
84156
84223
|
const isPressed = pressedRowKey === recordKey;
|
|
84157
84224
|
return {
|
|
84158
84225
|
onClick: (event) => handleRowClick(record, index2 ?? 0, event),
|