@zat-design/sisyphus-react 3.5.2-beta.1 → 3.5.2
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/es/ProTable/index.js +6 -11
- package/es/ProTable/utils.d.ts +0 -1
- package/es/ProTable/utils.js +0 -9
- package/lib/ProTable/index.js +5 -10
- package/lib/ProTable/utils.d.ts +0 -1
- package/lib/ProTable/utils.js +1 -10
- package/package.json +1 -1
package/es/ProTable/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import useAntdTable from './useAntdTable';
|
|
|
26
26
|
import empty from '../assets/empty.png';
|
|
27
27
|
import resetSvg from '../assets/reset.svg';
|
|
28
28
|
import customColumnSvg from '../assets/customColumn.svg';
|
|
29
|
-
import { formatColumn, getColumnDataIndex
|
|
29
|
+
import { formatColumn, getColumnDataIndex } from './utils';
|
|
30
30
|
import locale from '../locale';
|
|
31
31
|
var defaultCacheTime = 1; // columns 配置保存时间为一天
|
|
32
32
|
// 全局上下文
|
|
@@ -82,7 +82,7 @@ function ProTable(props) {
|
|
|
82
82
|
rowKey = _ref3.rowKey;
|
|
83
83
|
var initDataSource = dataSource === null || dataSource === void 0 ? void 0 : dataSource.map(function (item) {
|
|
84
84
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
85
|
-
rowKey:
|
|
85
|
+
rowKey: item === null || item === void 0 ? void 0 : item[rowKey]
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
88
|
var _useSetState = useSetState({
|
|
@@ -96,13 +96,8 @@ function ProTable(props) {
|
|
|
96
96
|
dataSource: initDataSource
|
|
97
97
|
});
|
|
98
98
|
}, [initDataSource]);
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
rowKey: getRowKey(rowKey, item)
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
var originalObj = _originalDataSource ? keyBy(_originalDataSource, 'rowKey') : undefined;
|
|
105
|
-
var dataSourceObj = _dataSource ? keyBy(_dataSource, 'rowKey') : {};
|
|
99
|
+
var originalObj = originalDataSource ? keyBy(originalDataSource, rowKey) : undefined;
|
|
100
|
+
var dataSourceObj = _dataSource ? keyBy(_dataSource, rowKey) : {};
|
|
106
101
|
var propsColumnObj = useMemo(function () {
|
|
107
102
|
return propsColumns.reduce(function (acc, cur) {
|
|
108
103
|
// @ts-ignore
|
|
@@ -193,7 +188,7 @@ function ProTable(props) {
|
|
|
193
188
|
return !(item === null || item === void 0 ? void 0 : item.delete);
|
|
194
189
|
});
|
|
195
190
|
newColumns === null || newColumns === void 0 ? void 0 : newColumns.forEach(function (item) {
|
|
196
|
-
formatColumn(item, originalObj, dataSourceObj,
|
|
191
|
+
formatColumn(item, originalObj, dataSourceObj, rowKey);
|
|
197
192
|
});
|
|
198
193
|
return newColumns;
|
|
199
194
|
}, [curColumns, handleResize]);
|
|
@@ -432,7 +427,7 @@ function ProTable(props) {
|
|
|
432
427
|
return renderSummary();
|
|
433
428
|
} : summary,
|
|
434
429
|
rowClassName: function rowClassName(record, index) {
|
|
435
|
-
if (originalDataSource && !originalObj.hasOwnProperty(get(record,
|
|
430
|
+
if (originalDataSource && !originalObj.hasOwnProperty(get(record, rowKey))) {
|
|
436
431
|
return 'new-cell';
|
|
437
432
|
}
|
|
438
433
|
}
|
package/es/ProTable/utils.d.ts
CHANGED
package/es/ProTable/utils.js
CHANGED
|
@@ -396,13 +396,4 @@ export var getParentElement = function getParentElement(element, name) {
|
|
|
396
396
|
*/
|
|
397
397
|
export var isListResult = function isListResult(data) {
|
|
398
398
|
return data.hasOwnProperty('total') && data.hasOwnProperty('list');
|
|
399
|
-
};
|
|
400
|
-
export var getRowKey = function getRowKey(rowKey, record) {
|
|
401
|
-
// 默认取id
|
|
402
|
-
var key = record.rowKey || 'id';
|
|
403
|
-
if (rowKey) {
|
|
404
|
-
var _ref;
|
|
405
|
-
key = (_ref = typeof rowKey === 'function' ? rowKey(record) : record[rowKey]) !== null && _ref !== void 0 ? _ref : key;
|
|
406
|
-
}
|
|
407
|
-
return key;
|
|
408
399
|
};
|
package/lib/ProTable/index.js
CHANGED
|
@@ -86,7 +86,7 @@ function ProTable(props) {
|
|
|
86
86
|
rowKey = _ref3.rowKey;
|
|
87
87
|
var initDataSource = dataSource === null || dataSource === void 0 ? void 0 : dataSource.map(function (item) {
|
|
88
88
|
return (0, _objectSpread4.default)((0, _objectSpread4.default)({}, item), {}, {
|
|
89
|
-
rowKey:
|
|
89
|
+
rowKey: item === null || item === void 0 ? void 0 : item[rowKey]
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
92
|
var _useSetState = (0, _ahooks.useSetState)({
|
|
@@ -100,13 +100,8 @@ function ProTable(props) {
|
|
|
100
100
|
dataSource: initDataSource
|
|
101
101
|
});
|
|
102
102
|
}, [initDataSource]);
|
|
103
|
-
var
|
|
104
|
-
|
|
105
|
-
rowKey: (0, _utils3.getRowKey)(rowKey, item)
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
var originalObj = _originalDataSource ? (0, _lodash.keyBy)(_originalDataSource, 'rowKey') : undefined;
|
|
109
|
-
var dataSourceObj = _dataSource ? (0, _lodash.keyBy)(_dataSource, 'rowKey') : {};
|
|
103
|
+
var originalObj = originalDataSource ? (0, _lodash.keyBy)(originalDataSource, rowKey) : undefined;
|
|
104
|
+
var dataSourceObj = _dataSource ? (0, _lodash.keyBy)(_dataSource, rowKey) : {};
|
|
110
105
|
var propsColumnObj = (0, _react.useMemo)(function () {
|
|
111
106
|
return propsColumns.reduce(function (acc, cur) {
|
|
112
107
|
// @ts-ignore
|
|
@@ -197,7 +192,7 @@ function ProTable(props) {
|
|
|
197
192
|
return !(item === null || item === void 0 ? void 0 : item.delete);
|
|
198
193
|
});
|
|
199
194
|
newColumns === null || newColumns === void 0 ? void 0 : newColumns.forEach(function (item) {
|
|
200
|
-
(0, _utils3.formatColumn)(item, originalObj, dataSourceObj,
|
|
195
|
+
(0, _utils3.formatColumn)(item, originalObj, dataSourceObj, rowKey);
|
|
201
196
|
});
|
|
202
197
|
return newColumns;
|
|
203
198
|
}, [curColumns, handleResize]);
|
|
@@ -436,7 +431,7 @@ function ProTable(props) {
|
|
|
436
431
|
return renderSummary();
|
|
437
432
|
} : summary,
|
|
438
433
|
rowClassName: function rowClassName(record, index) {
|
|
439
|
-
if (originalDataSource && !originalObj.hasOwnProperty((0, _lodash.get)(record,
|
|
434
|
+
if (originalDataSource && !originalObj.hasOwnProperty((0, _lodash.get)(record, rowKey))) {
|
|
440
435
|
return 'new-cell';
|
|
441
436
|
}
|
|
442
437
|
}
|
package/lib/ProTable/utils.d.ts
CHANGED
package/lib/ProTable/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.isListResult = exports.
|
|
7
|
+
exports.isListResult = exports.getParentElement = exports.getColumnDataIndex = exports.formatColumn = void 0;
|
|
8
8
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _moment15 = _interopRequireDefault(require("moment"));
|
|
@@ -403,13 +403,4 @@ var getParentElement = exports.getParentElement = function getParentElement(elem
|
|
|
403
403
|
*/
|
|
404
404
|
var isListResult = exports.isListResult = function isListResult(data) {
|
|
405
405
|
return data.hasOwnProperty('total') && data.hasOwnProperty('list');
|
|
406
|
-
};
|
|
407
|
-
var getRowKey = exports.getRowKey = function getRowKey(rowKey, record) {
|
|
408
|
-
// 默认取id
|
|
409
|
-
var key = record.rowKey || 'id';
|
|
410
|
-
if (rowKey) {
|
|
411
|
-
var _ref;
|
|
412
|
-
key = (_ref = typeof rowKey === 'function' ? rowKey(record) : record[rowKey]) !== null && _ref !== void 0 ? _ref : key;
|
|
413
|
-
}
|
|
414
|
-
return key;
|
|
415
406
|
};
|