@zat-design/sisyphus-react 4.1.2 → 4.1.3-beta.1
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.
|
@@ -27,6 +27,8 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
27
27
|
var columnDataSourceRefCache = new Map();
|
|
28
28
|
/** 追踪 component 函数引用,用于检测外部状态(如异步 list)变化导致的闭包更新 */
|
|
29
29
|
var columnComponentRefCache = new Map();
|
|
30
|
+
/** 追踪 filterInList 列表长度,用于检测行增删导致的索引偏移 */
|
|
31
|
+
var columnListLengthCache = new Map();
|
|
30
32
|
|
|
31
33
|
// 渲染操作栏
|
|
32
34
|
var getActionColumn = config => {
|
|
@@ -377,18 +379,37 @@ export var transformColumns = function transformColumns() {
|
|
|
377
379
|
|
|
378
380
|
// 精准控制单元格更新,减少不必要的渲染
|
|
379
381
|
if (!item.shouldCellUpdate) {
|
|
382
|
+
var _index, _item$fieldProps;
|
|
380
383
|
var hasComponent = isFunction(item.component);
|
|
381
384
|
var columnCacheKey = `${Array.isArray(name) ? name.join('.') : String(name)}::${String(columnName)}`;
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
385
|
+
|
|
386
|
+
// Fix 问题1:用原始列引用(克隆前)比对 dataSource
|
|
387
|
+
// cloneDeepFilterNode 每次产生新引用,在 shouldCellUpdate 内更新 cache 只会让第一行触发更新,其余行跳过
|
|
388
|
+
var originalFieldProps = (_index = columns[index]) === null || _index === void 0 ? void 0 : _index.fieldProps;
|
|
389
|
+
var originalDataSourceRef = !isFunction(originalFieldProps) ? originalFieldProps === null || originalFieldProps === void 0 ? void 0 : originalFieldProps.dataSource : undefined;
|
|
390
|
+
var prevDataSourceRef = columnDataSourceRefCache.get(columnCacheKey);
|
|
391
|
+
var dataSourceChanged = originalDataSourceRef !== undefined && prevDataSourceRef !== originalDataSourceRef;
|
|
392
|
+
if (dataSourceChanged) {
|
|
393
|
+
columnDataSourceRefCache.set(columnCacheKey, originalDataSourceRef);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// Fix 问题2:检测 filterInList 列的行增删,避免行索引移位时 shouldUpdate 闭包中 index 失效
|
|
397
|
+
var filterInListEnabled = !isFunction(item === null || item === void 0 ? void 0 : item.fieldProps) && (item === null || item === void 0 || (_item$fieldProps = item.fieldProps) === null || _item$fieldProps === void 0 ? void 0 : _item$fieldProps.filterInList);
|
|
398
|
+
var filterListChanged = false;
|
|
399
|
+
if (filterInListEnabled) {
|
|
400
|
+
var _config$tableLength, _columnListLengthCach;
|
|
401
|
+
var currentListLen = (_config$tableLength = config.tableLength) !== null && _config$tableLength !== void 0 ? _config$tableLength : 0;
|
|
402
|
+
var prevListLen = (_columnListLengthCach = columnListLengthCache.get(columnCacheKey)) !== null && _columnListLengthCach !== void 0 ? _columnListLengthCach : -1;
|
|
403
|
+
if (prevListLen !== currentListLen) {
|
|
404
|
+
filterListChanged = true;
|
|
405
|
+
columnListLengthCache.set(columnCacheKey, currentListLen);
|
|
391
406
|
}
|
|
407
|
+
}
|
|
408
|
+
item.shouldCellUpdate = (record, prevRecord) => {
|
|
409
|
+
// dataSource 变化:所有行均需更新(修复异步加载 dataSource 只更新第一行的问题)
|
|
410
|
+
if (dataSourceChanged) return true;
|
|
411
|
+
// filterInList 列的行数变化:强制全量重渲染,避免行索引移位时闭包失效导致显示错误
|
|
412
|
+
if (filterListChanged) return true;
|
|
392
413
|
if ((record === null || record === void 0 ? void 0 : record.rowKey) !== (prevRecord === null || prevRecord === void 0 ? void 0 : prevRecord.rowKey)) {
|
|
393
414
|
return true;
|
|
394
415
|
}
|
|
@@ -33,6 +33,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
33
33
|
var columnDataSourceRefCache = new Map();
|
|
34
34
|
/** 追踪 component 函数引用,用于检测外部状态(如异步 list)变化导致的闭包更新 */
|
|
35
35
|
var columnComponentRefCache = new Map();
|
|
36
|
+
/** 追踪 filterInList 列表长度,用于检测行增删导致的索引偏移 */
|
|
37
|
+
var columnListLengthCache = new Map();
|
|
36
38
|
|
|
37
39
|
// 渲染操作栏
|
|
38
40
|
var getActionColumn = config => {
|
|
@@ -383,18 +385,37 @@ var transformColumns = exports.transformColumns = function transformColumns() {
|
|
|
383
385
|
|
|
384
386
|
// 精准控制单元格更新,减少不必要的渲染
|
|
385
387
|
if (!item.shouldCellUpdate) {
|
|
388
|
+
var _index, _item$fieldProps;
|
|
386
389
|
var hasComponent = (0, _lodash.isFunction)(item.component);
|
|
387
390
|
var columnCacheKey = `${Array.isArray(name) ? name.join('.') : String(name)}::${String(columnName)}`;
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
391
|
+
|
|
392
|
+
// Fix 问题1:用原始列引用(克隆前)比对 dataSource
|
|
393
|
+
// cloneDeepFilterNode 每次产生新引用,在 shouldCellUpdate 内更新 cache 只会让第一行触发更新,其余行跳过
|
|
394
|
+
var originalFieldProps = (_index = columns[index]) === null || _index === void 0 ? void 0 : _index.fieldProps;
|
|
395
|
+
var originalDataSourceRef = !(0, _lodash.isFunction)(originalFieldProps) ? originalFieldProps === null || originalFieldProps === void 0 ? void 0 : originalFieldProps.dataSource : undefined;
|
|
396
|
+
var prevDataSourceRef = columnDataSourceRefCache.get(columnCacheKey);
|
|
397
|
+
var dataSourceChanged = originalDataSourceRef !== undefined && prevDataSourceRef !== originalDataSourceRef;
|
|
398
|
+
if (dataSourceChanged) {
|
|
399
|
+
columnDataSourceRefCache.set(columnCacheKey, originalDataSourceRef);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// Fix 问题2:检测 filterInList 列的行增删,避免行索引移位时 shouldUpdate 闭包中 index 失效
|
|
403
|
+
var filterInListEnabled = !(0, _lodash.isFunction)(item === null || item === void 0 ? void 0 : item.fieldProps) && (item === null || item === void 0 || (_item$fieldProps = item.fieldProps) === null || _item$fieldProps === void 0 ? void 0 : _item$fieldProps.filterInList);
|
|
404
|
+
var filterListChanged = false;
|
|
405
|
+
if (filterInListEnabled) {
|
|
406
|
+
var _config$tableLength, _columnListLengthCach;
|
|
407
|
+
var currentListLen = (_config$tableLength = config.tableLength) !== null && _config$tableLength !== void 0 ? _config$tableLength : 0;
|
|
408
|
+
var prevListLen = (_columnListLengthCach = columnListLengthCache.get(columnCacheKey)) !== null && _columnListLengthCach !== void 0 ? _columnListLengthCach : -1;
|
|
409
|
+
if (prevListLen !== currentListLen) {
|
|
410
|
+
filterListChanged = true;
|
|
411
|
+
columnListLengthCache.set(columnCacheKey, currentListLen);
|
|
397
412
|
}
|
|
413
|
+
}
|
|
414
|
+
item.shouldCellUpdate = (record, prevRecord) => {
|
|
415
|
+
// dataSource 变化:所有行均需更新(修复异步加载 dataSource 只更新第一行的问题)
|
|
416
|
+
if (dataSourceChanged) return true;
|
|
417
|
+
// filterInList 列的行数变化:强制全量重渲染,避免行索引移位时闭包失效导致显示错误
|
|
418
|
+
if (filterListChanged) return true;
|
|
398
419
|
if ((record === null || record === void 0 ? void 0 : record.rowKey) !== (prevRecord === null || prevRecord === void 0 ? void 0 : prevRecord.rowKey)) {
|
|
399
420
|
return true;
|
|
400
421
|
}
|