@zat-design/sisyphus-react 4.1.1 → 4.1.2-beta.10
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/.claudeignore +40 -0
- package/dist/index.esm.css +1 -1
- package/dist/less.esm.css +1 -1
- package/es/ProDrawerForm/components/ProDrawer/index.js +5 -2
- package/es/ProEditTable/components/RcTable/BaseTable.js +12 -16
- package/es/ProEditTable/components/RcTable/DraggableTable.js +17 -17
- package/es/ProEditTable/components/RenderField/index.js +298 -96
- package/es/ProEditTable/index.js +86 -69
- package/es/ProEditTable/propsType.d.ts +6 -1
- package/es/ProEditTable/style/index.less +8 -0
- package/es/ProEditTable/utils/config.d.ts +1 -1
- package/es/ProEditTable/utils/config.js +16 -9
- package/es/ProEditTable/utils/index.js +77 -22
- package/es/ProEditTable/utils/useShouldUpdateForTable.d.ts +1 -0
- package/es/ProEditTable/utils/useShouldUpdateForTable.js +37 -10
- package/es/ProForm/components/base/DatePicker/index.js +1 -7
- package/es/ProForm/components/base/RangePicker/index.js +62 -8
- package/es/ProForm/components/combination/Container/index.js +2 -1
- package/es/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
- package/es/ProForm/components/combination/Group/component/ComRender.js +15 -11
- package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +61 -7
- package/es/ProForm/components/combination/Group/style/index.less +26 -1
- package/es/ProForm/components/combination/Group/utils/index.d.ts +10 -10
- package/es/ProForm/components/combination/ProCascader/propsType.d.ts +1 -1
- package/es/ProForm/propsType.d.ts +3 -3
- package/es/ProForm/utils/transformValue.d.ts +1 -1
- package/es/ProForm/utils/useForm.d.ts +1 -1
- package/es/ProForm/utils/useWatch.d.ts +2 -1
- package/es/ProForm/utils/useWatch.js +3 -1
- package/es/ProLayout/components/ProCollapse/index.js +4 -3
- package/es/ProSelect/index.js +117 -62
- package/es/ProUpload/propsType.d.ts +1 -1
- package/es/ProUpload/style/index.less +3 -3
- package/lib/ProDrawerForm/components/ProDrawer/index.js +5 -2
- package/lib/ProEditTable/components/RcTable/BaseTable.js +11 -15
- package/lib/ProEditTable/components/RcTable/DraggableTable.js +17 -17
- package/lib/ProEditTable/components/RenderField/index.js +298 -96
- package/lib/ProEditTable/index.js +86 -69
- package/lib/ProEditTable/propsType.d.ts +6 -1
- package/lib/ProEditTable/style/index.less +8 -0
- package/lib/ProEditTable/utils/config.d.ts +1 -1
- package/lib/ProEditTable/utils/config.js +16 -9
- package/lib/ProEditTable/utils/index.js +78 -21
- package/lib/ProEditTable/utils/useShouldUpdateForTable.d.ts +1 -0
- package/lib/ProEditTable/utils/useShouldUpdateForTable.js +37 -10
- package/lib/ProForm/components/base/DatePicker/index.js +1 -7
- package/lib/ProForm/components/base/RangePicker/index.js +62 -8
- package/lib/ProForm/components/combination/Container/index.js +2 -1
- package/lib/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
- package/lib/ProForm/components/combination/Group/component/ComRender.js +15 -11
- package/lib/ProForm/components/combination/Group/component/FlexibleGroup.js +61 -7
- package/lib/ProForm/components/combination/Group/style/index.less +26 -1
- package/lib/ProForm/components/combination/ProCascader/propsType.d.ts +1 -1
- package/lib/ProForm/propsType.d.ts +3 -3
- package/lib/ProForm/utils/transformValue.d.ts +1 -1
- package/lib/ProForm/utils/useForm.d.ts +1 -1
- package/lib/ProForm/utils/useWatch.d.ts +2 -1
- package/lib/ProForm/utils/useWatch.js +3 -1
- package/lib/ProLayout/components/ProCollapse/index.js +6 -3
- package/lib/ProSelect/index.js +115 -61
- package/lib/ProUpload/propsType.d.ts +1 -1
- package/lib/ProUpload/style/index.less +3 -3
- package/package.json +4 -2
package/es/ProEditTable/index.js
CHANGED
|
@@ -31,7 +31,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
31
31
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
32
32
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
33
|
var ProEditTable = (_ref, ref) => {
|
|
34
|
-
var _resetProps$id, _resetProps$id$split, _ref2, _formFieldProps$shoul, _themeConfig$data2
|
|
34
|
+
var _resetProps$id, _resetProps$id$split, _ref2, _formFieldProps$shoul, _themeConfig$data2;
|
|
35
35
|
var _ref$value = _ref.value,
|
|
36
36
|
value = _ref$value === void 0 ? [] : _ref$value,
|
|
37
37
|
onChange = _ref.onChange,
|
|
@@ -150,10 +150,13 @@ var ProEditTable = (_ref, ref) => {
|
|
|
150
150
|
var getRowKey = useCallback(record => {
|
|
151
151
|
var key = record.rowKey || getRandom();
|
|
152
152
|
if (rowKey) {
|
|
153
|
-
var
|
|
154
|
-
|
|
153
|
+
var userKey = isFunction(rowKey) ? rowKey(record) : record[rowKey];
|
|
154
|
+
// 检查用户返回的 key 是否有效(不是 null、undefined、NaN 或空字符串)
|
|
155
|
+
if (userKey != null && !Number.isNaN(userKey) && userKey !== '') {
|
|
156
|
+
key = userKey;
|
|
157
|
+
}
|
|
155
158
|
}
|
|
156
|
-
return key;
|
|
159
|
+
return String(key); // 确保返回字符串
|
|
157
160
|
}, [rowKey]);
|
|
158
161
|
var originalValues = useMemo(() => {
|
|
159
162
|
var _originalArr$every, _originalArr$some;
|
|
@@ -186,7 +189,7 @@ var ProEditTable = (_ref, ref) => {
|
|
|
186
189
|
|
|
187
190
|
// 分页变更
|
|
188
191
|
var handlePageChange = useCallback( /*#__PURE__*/function () {
|
|
189
|
-
var
|
|
192
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(current, pageSize) {
|
|
190
193
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
191
194
|
while (1) switch (_context.prev = _context.next) {
|
|
192
195
|
case 0:
|
|
@@ -232,47 +235,52 @@ var ProEditTable = (_ref, ref) => {
|
|
|
232
235
|
}, _callee, null, [[0, 10]]);
|
|
233
236
|
}));
|
|
234
237
|
return function (_x, _x2) {
|
|
235
|
-
return
|
|
238
|
+
return _ref4.apply(this, arguments);
|
|
236
239
|
};
|
|
237
240
|
}(), [pagination, page.pageSize, form, name]);
|
|
238
|
-
var config =
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
241
|
+
var config = useMemo(() => {
|
|
242
|
+
var _resetProps$otherProp;
|
|
243
|
+
return _objectSpread({
|
|
244
|
+
form,
|
|
245
|
+
mode,
|
|
246
|
+
isView,
|
|
247
|
+
viewEmpty,
|
|
248
|
+
disabled,
|
|
249
|
+
cellNamePath,
|
|
250
|
+
forceUpdate,
|
|
251
|
+
insertType,
|
|
252
|
+
emptyBtnText,
|
|
253
|
+
editingKeys,
|
|
254
|
+
actionWidth,
|
|
255
|
+
actionProps,
|
|
256
|
+
toolbarProps,
|
|
257
|
+
setState,
|
|
258
|
+
selectedRowKeys,
|
|
259
|
+
selectedRows,
|
|
260
|
+
onlyOneLineMsg,
|
|
261
|
+
deletePoConfirmMsg,
|
|
262
|
+
mulDeletePoConfirmMsg,
|
|
263
|
+
virtualKey,
|
|
264
|
+
requiredAlign,
|
|
265
|
+
name: isArray(name) ? name : [name],
|
|
266
|
+
// name需要处理成namePath形式,为兼容多路径
|
|
267
|
+
namePath,
|
|
268
|
+
tableRef,
|
|
269
|
+
max,
|
|
270
|
+
tableLength: value === null || value === void 0 ? void 0 : value.length,
|
|
271
|
+
page,
|
|
272
|
+
originalValues,
|
|
273
|
+
prefixCls,
|
|
274
|
+
rowDisabled,
|
|
275
|
+
actionDirection,
|
|
276
|
+
diffConfig: _objectSpread(_objectSpread({}, resetProps === null || resetProps === void 0 || (_resetProps$otherProp = resetProps.otherProps) === null || _resetProps$otherProp === void 0 ? void 0 : _resetProps$otherProp.diffConfig), diffConfig),
|
|
277
|
+
shouldUpdateDebounce,
|
|
278
|
+
getIsNew,
|
|
279
|
+
handlePageChange
|
|
280
|
+
}, resetProps);
|
|
281
|
+
}, [actionDirection, actionProps, actionWidth, cellNamePath, deletePoConfirmMsg, disabled, diffConfig, editingKeys, emptyBtnText, form,
|
|
282
|
+
// forceUpdate 不应该作为依赖项,因为它是触发刷新的信号,而非用于比较的数据
|
|
283
|
+
getIsNew, handlePageChange, insertType, isView, max, mode, mulDeletePoConfirmMsg, name, namePath, onlyOneLineMsg, originalValues, prefixCls, requiredAlign, resetProps, rowDisabled, selectedRowKeys, selectedRows, shouldUpdateDebounce, tableRef, toolbarProps, value === null || value === void 0 ? void 0 : value.length, viewEmpty, virtualKey, page]);
|
|
276
284
|
|
|
277
285
|
// 编辑行设置下样式
|
|
278
286
|
var _rowClassName = record => {
|
|
@@ -330,7 +338,7 @@ var ProEditTable = (_ref, ref) => {
|
|
|
330
338
|
|
|
331
339
|
// 空列表状态
|
|
332
340
|
var emptyDom = useMemo(() => () => {
|
|
333
|
-
var _filter,
|
|
341
|
+
var _filter, _ref5;
|
|
334
342
|
return /*#__PURE__*/_jsxs("div", {
|
|
335
343
|
className: "com-empty",
|
|
336
344
|
children: [/*#__PURE__*/_jsx("img", {
|
|
@@ -341,7 +349,7 @@ var ProEditTable = (_ref, ref) => {
|
|
|
341
349
|
className: "content",
|
|
342
350
|
children: disabled || isForbiddenBtn('add') ? locale.ProEditTable.noData : /*#__PURE__*/_jsxs(_Fragment, {
|
|
343
351
|
children: [locale.ProEditTable.noData, "\uFF0C", /*#__PURE__*/_jsx(RenderToolbar, _objectSpread({}, _objectSpread(_objectSpread({}, config), {}, {
|
|
344
|
-
toolbarProps: toolbarProps === null || toolbarProps === void 0 || (_filter = (
|
|
352
|
+
toolbarProps: toolbarProps === null || toolbarProps === void 0 || (_filter = (_ref5 = toolbarProps).filter) === null || _filter === void 0 ? void 0 : _filter.call(_ref5, item => item.type === 'add' || (item === null || item === void 0 ? void 0 : item.persistence)),
|
|
345
353
|
dataSource: []
|
|
346
354
|
})))]
|
|
347
355
|
})
|
|
@@ -367,7 +375,7 @@ var ProEditTable = (_ref, ref) => {
|
|
|
367
375
|
};
|
|
368
376
|
var _columns = useMemo(() => {
|
|
369
377
|
return transformColumns(columns, config);
|
|
370
|
-
}, [disabled, forceUpdate, columns, page, actionProps, editingKeys, cellNamePath]);
|
|
378
|
+
}, [disabled, forceUpdate, columns, page, actionProps, editingKeys, cellNamePath, config]);
|
|
371
379
|
var initDataSource = () => {
|
|
372
380
|
var _value$every, _value$some;
|
|
373
381
|
// 检查每一项是否有 rowKey 或通过 rowKey 字段获取的 key
|
|
@@ -416,6 +424,36 @@ var ProEditTable = (_ref, ref) => {
|
|
|
416
424
|
rowSelection: renderRowSelection()
|
|
417
425
|
}) : summary;
|
|
418
426
|
var TableComponent = draggable ? DraggableTable : BaseTable;
|
|
427
|
+
|
|
428
|
+
// 给每个 record 附加编辑状态标识,让 shouldCellUpdate 能检测到状态变化
|
|
429
|
+
var enrichedValue = useMemo(() => {
|
|
430
|
+
if (!virtualKey) return value;
|
|
431
|
+
return value === null || value === void 0 ? void 0 : value.map(record => _objectSpread(_objectSpread({}, record), {}, {
|
|
432
|
+
_isEditing: editingKeys.includes(record.rowKey) || record._addFlag
|
|
433
|
+
}));
|
|
434
|
+
}, [value, virtualKey, editingKeys]);
|
|
435
|
+
var tableProps = useMemo(() => ({
|
|
436
|
+
rowKey,
|
|
437
|
+
value: enrichedValue,
|
|
438
|
+
headerRender,
|
|
439
|
+
tableRef,
|
|
440
|
+
className: _className,
|
|
441
|
+
columns: _columns,
|
|
442
|
+
renderRowSelection,
|
|
443
|
+
rowClassName: _rowClassName,
|
|
444
|
+
disabled,
|
|
445
|
+
virtualKey,
|
|
446
|
+
editingKeys,
|
|
447
|
+
isHideCheckBox,
|
|
448
|
+
rowDraggable,
|
|
449
|
+
pagination,
|
|
450
|
+
scroll,
|
|
451
|
+
summary: _summary,
|
|
452
|
+
page,
|
|
453
|
+
formatMessage,
|
|
454
|
+
locale,
|
|
455
|
+
handlePageChange
|
|
456
|
+
}), [_className, _columns, _rowClassName, disabled, editingKeys, formatMessage, handlePageChange, headerRender, isHideCheckBox, locale, page, pagination, renderRowSelection, rowDraggable, rowKey, scroll, _summary, tableRef, enrichedValue, virtualKey]);
|
|
419
457
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
420
458
|
children: [/*#__PURE__*/_jsx(ConfigProvider, {
|
|
421
459
|
renderEmpty: value !== null && value !== void 0 && value.length ? undefined : emptyDom,
|
|
@@ -426,28 +464,7 @@ var ProEditTable = (_ref, ref) => {
|
|
|
426
464
|
onDragEnd,
|
|
427
465
|
draggable
|
|
428
466
|
},
|
|
429
|
-
tableProps:
|
|
430
|
-
rowKey,
|
|
431
|
-
value,
|
|
432
|
-
headerRender,
|
|
433
|
-
tableRef,
|
|
434
|
-
className: _className,
|
|
435
|
-
columns: _columns,
|
|
436
|
-
renderRowSelection,
|
|
437
|
-
rowClassName: _rowClassName,
|
|
438
|
-
disabled,
|
|
439
|
-
virtualKey,
|
|
440
|
-
editingKeys,
|
|
441
|
-
isHideCheckBox,
|
|
442
|
-
rowDraggable,
|
|
443
|
-
pagination,
|
|
444
|
-
scroll,
|
|
445
|
-
summary: _summary,
|
|
446
|
-
page,
|
|
447
|
-
formatMessage,
|
|
448
|
-
locale,
|
|
449
|
-
handlePageChange
|
|
450
|
-
}
|
|
467
|
+
tableProps: tableProps
|
|
451
468
|
}))
|
|
452
469
|
}), !isView && value !== null && value !== void 0 && value.length ? toolbarSticky ? /*#__PURE__*/_jsx(Affix, _objectSpread(_objectSpread({
|
|
453
470
|
ref: affixRef
|
|
@@ -130,6 +130,11 @@ export type RequiredFn<T = any> = ReactiveFunction<T, boolean | boolean[]>;
|
|
|
130
130
|
* @template T 记录类型
|
|
131
131
|
*/
|
|
132
132
|
export type viewRenderFn<T = any> = (text?: any, record?: T, options?: OptionsProps) => string | number | ReactNode | void;
|
|
133
|
+
/**
|
|
134
|
+
* 组件渲染函数类型(与 ReactiveFunction 保持一致)
|
|
135
|
+
* @template T 记录类型
|
|
136
|
+
*/
|
|
137
|
+
export type ComponentRenderFn<T = any> = ReactiveFunction<T, string | number | ReactNode | void>;
|
|
133
138
|
/**
|
|
134
139
|
* 表格列属性接口
|
|
135
140
|
* @template Values 值类型
|
|
@@ -153,7 +158,7 @@ export interface ProColumnsProps<Values = any, T = any> extends Omit<FormItemPro
|
|
|
153
158
|
icon?: string | ReactNode;
|
|
154
159
|
} & TooltipProps);
|
|
155
160
|
/** 组件 */
|
|
156
|
-
component?: string | number | ReactNode |
|
|
161
|
+
component?: string | number | ReactNode | ComponentRenderFn<T>;
|
|
157
162
|
/** 视图渲染 */
|
|
158
163
|
viewRender?: string | number | ReactNode | viewRenderFn<T>;
|
|
159
164
|
/** 隐藏的字段名 */
|
|
@@ -425,4 +425,12 @@
|
|
|
425
425
|
table tr th.@{ant-prefix}-table-selection-column.@{ant-prefix}-table-cell-fix-start{
|
|
426
426
|
text-align: right;
|
|
427
427
|
}
|
|
428
|
+
table .@{ant-prefix}-table-thead{
|
|
429
|
+
th.@{ant-prefix}-table-selection-column.@{ant-prefix}-table-cell-fix-start{
|
|
430
|
+
text-align: left;
|
|
431
|
+
.@{ant-prefix}-table-selection{
|
|
432
|
+
padding-left: 27px;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
428
436
|
}
|
|
@@ -16,7 +16,7 @@ export declare const defaultMultipleActionKeys: string[];
|
|
|
16
16
|
export declare const defaultEditingActionKeys: string[];
|
|
17
17
|
export declare const defaultToolbarKeys: string[];
|
|
18
18
|
export declare const actions: {
|
|
19
|
-
edit: ({ record, editingKeys, setState, form, virtualRowName, virtualKey, onlyOneLineMsg
|
|
19
|
+
edit: ({ record, editingKeys, setState, form, virtualRowName, virtualKey, onlyOneLineMsg }: any) => boolean;
|
|
20
20
|
save: ({ record, editingKeys, setState, form, rowName, virtualRowName, result }: any) => Promise<void>;
|
|
21
21
|
cancel: ({ name, record, editingKeys, setState, form, virtualRowName, virtualKey }: any) => void;
|
|
22
22
|
delete: ({ name, record, editingKeys, setState, form, virtualKey, onlyOneLineMsg }: any) => boolean;
|
|
@@ -167,8 +167,8 @@ export var actions = {
|
|
|
167
167
|
},
|
|
168
168
|
add: function () {
|
|
169
169
|
var _add = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref5) {
|
|
170
|
-
var _tableRef$current
|
|
171
|
-
var result, insertType, editingKeys, setState, form, name, virtualName, virtualKey, onlyOneLineMsg, tableRef, _ref5$prefixCls, prefixCls, page, handlePageChange, nextData, rowKey, addData, nextPageNum, nextEditingKeys;
|
|
170
|
+
var _tableRef$current;
|
|
171
|
+
var result, insertType, editingKeys, setState, form, name, virtualName, virtualKey, onlyOneLineMsg, tableRef, _ref5$prefixCls, prefixCls, page, handlePageChange, nextData, rowKey, addData, nextPageNum, nextEditingKeys, tableBody;
|
|
172
172
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
173
173
|
while (1) switch (_context4.prev = _context4.next) {
|
|
174
174
|
case 0:
|
|
@@ -228,17 +228,24 @@ export var actions = {
|
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
230
|
form.setFieldValue(name, nextData);
|
|
231
|
-
(_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 || (_tableRef$current = _tableRef$current.children[0]) === null || _tableRef$current === void 0
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
231
|
+
tableBody = (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 || (_tableRef$current = _tableRef$current.children[0]) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.querySelector(`.${prefixCls}-table-body`);
|
|
232
|
+
if (tableBody) {
|
|
233
|
+
// 等待新行渲染完毕再读取 scrollHeight,确保能滚动到真正的底部
|
|
234
|
+
requestAnimationFrame(() => {
|
|
235
|
+
var _tableBody$scrollTo;
|
|
236
|
+
(_tableBody$scrollTo = tableBody.scrollTo) === null || _tableBody$scrollTo === void 0 || _tableBody$scrollTo.call(tableBody, {
|
|
237
|
+
top: insertType === 'before' ? 0 : tableBody.scrollHeight,
|
|
238
|
+
behavior: 'smooth'
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
}
|
|
235
242
|
if (!virtualKey) {
|
|
236
|
-
_context4.next =
|
|
243
|
+
_context4.next = 16;
|
|
237
244
|
break;
|
|
238
245
|
}
|
|
239
|
-
_context4.next =
|
|
246
|
+
_context4.next = 16;
|
|
240
247
|
return form.validateFields([name]);
|
|
241
|
-
case
|
|
248
|
+
case 16:
|
|
242
249
|
case "end":
|
|
243
250
|
return _context4.stop();
|
|
244
251
|
}
|
|
@@ -22,10 +22,13 @@ import { filterInternalFields } from "../../ProForm/utils";
|
|
|
22
22
|
import ProTooltip from "../../ProTooltip";
|
|
23
23
|
import { RenderField, ActionButton } from "../components";
|
|
24
24
|
import locale from "../../locale";
|
|
25
|
-
|
|
26
|
-
// 渲染操作栏
|
|
27
25
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
28
26
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
|
+
var columnDataSourceRefCache = new Map();
|
|
28
|
+
/** 追踪 component 函数引用,用于检测外部状态(如异步 list)变化导致的闭包更新 */
|
|
29
|
+
var columnComponentRefCache = new Map();
|
|
30
|
+
|
|
31
|
+
// 渲染操作栏
|
|
29
32
|
var getActionColumn = config => {
|
|
30
33
|
var _cloneDeepWith = cloneDeepWith(config, value => {
|
|
31
34
|
if ( /*#__PURE__*/React.isValidElement(value)) {
|
|
@@ -41,7 +44,8 @@ var getActionColumn = config => {
|
|
|
41
44
|
actionProps = _cloneDeepWith.actionProps,
|
|
42
45
|
page = _cloneDeepWith.page,
|
|
43
46
|
rowDisabled = _cloneDeepWith.rowDisabled,
|
|
44
|
-
actionDirection = _cloneDeepWith.actionDirection
|
|
47
|
+
actionDirection = _cloneDeepWith.actionDirection,
|
|
48
|
+
editingKeys = _cloneDeepWith.editingKeys;
|
|
45
49
|
var pageNum = tools.calc(page.pageNum, '-', 1);
|
|
46
50
|
var firstIndex = tools.calc(pageNum, '*', page.pageSize);
|
|
47
51
|
// actionProps配置为false 默认不插入
|
|
@@ -89,7 +93,7 @@ var getActionColumn = config => {
|
|
|
89
93
|
action.onEvent = /*#__PURE__*/function () {
|
|
90
94
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(record, _ref) {
|
|
91
95
|
var _form$getFieldValue;
|
|
92
|
-
var index, form, name, namePath, tableLength, selectedRows, rowName, lastRecord, onEvent, result, actionHandler;
|
|
96
|
+
var index, form, name, namePath, tableLength, selectedRows, rowName, _isEditing, lastRecord, onEvent, result, actionHandler;
|
|
93
97
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
94
98
|
while (1) switch (_context.prev = _context.next) {
|
|
95
99
|
case 0:
|
|
@@ -97,33 +101,39 @@ var getActionColumn = config => {
|
|
|
97
101
|
index = tools.calc(firstIndex, '+', index);
|
|
98
102
|
rowName = [...virtualRowName, index];
|
|
99
103
|
if (!(type === 'save')) {
|
|
100
|
-
_context.next =
|
|
104
|
+
_context.next = 15;
|
|
101
105
|
break;
|
|
102
106
|
}
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
// 判断该行是否处于编辑状态
|
|
108
|
+
_isEditing = !virtualKey || editingKeys.includes(record.rowKey) || record._addFlag; // 只有编辑中的行才需要校验
|
|
109
|
+
if (!_isEditing) {
|
|
110
|
+
_context.next = 15;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
_context.prev = 6;
|
|
114
|
+
_context.next = 9;
|
|
105
115
|
return customValidate(validateKeys, form, rowName);
|
|
106
|
-
case 7:
|
|
107
|
-
_context.next = 13;
|
|
108
|
-
break;
|
|
109
116
|
case 9:
|
|
110
|
-
_context.
|
|
111
|
-
|
|
117
|
+
_context.next = 15;
|
|
118
|
+
break;
|
|
119
|
+
case 11:
|
|
120
|
+
_context.prev = 11;
|
|
121
|
+
_context.t0 = _context["catch"](6);
|
|
112
122
|
handleScrollToError();
|
|
113
123
|
return _context.abrupt("return", Promise.reject(_context.t0));
|
|
114
|
-
case
|
|
124
|
+
case 15:
|
|
115
125
|
// 编辑状态使用自定义form值,非编辑状态直接使用行数据
|
|
116
126
|
lastRecord = filterInternalFields((_form$getFieldValue = form.getFieldValue(rowName)) !== null && _form$getFieldValue !== void 0 ? _form$getFieldValue : record); // 新增事件可以设置初始默认值,当做函数的出参导出
|
|
117
127
|
onEvent = onClick || onHandle;
|
|
118
128
|
if (onEvent) {
|
|
119
|
-
_context.next =
|
|
129
|
+
_context.next = 21;
|
|
120
130
|
break;
|
|
121
131
|
}
|
|
122
132
|
result = true;
|
|
123
|
-
_context.next =
|
|
133
|
+
_context.next = 24;
|
|
124
134
|
break;
|
|
125
|
-
case
|
|
126
|
-
_context.next =
|
|
135
|
+
case 21:
|
|
136
|
+
_context.next = 23;
|
|
127
137
|
return onEvent === null || onEvent === void 0 ? void 0 : onEvent(lastRecord, {
|
|
128
138
|
form,
|
|
129
139
|
index,
|
|
@@ -132,9 +142,9 @@ var getActionColumn = config => {
|
|
|
132
142
|
namePath,
|
|
133
143
|
selectedRows
|
|
134
144
|
});
|
|
135
|
-
case
|
|
145
|
+
case 23:
|
|
136
146
|
result = _context.sent;
|
|
137
|
-
case
|
|
147
|
+
case 24:
|
|
138
148
|
if (result !== false && type !== 'custom') {
|
|
139
149
|
actionHandler = actions[type];
|
|
140
150
|
actionHandler(_objectSpread(_objectSpread({}, config), {}, {
|
|
@@ -145,11 +155,11 @@ var getActionColumn = config => {
|
|
|
145
155
|
validateKeys
|
|
146
156
|
}));
|
|
147
157
|
}
|
|
148
|
-
case
|
|
158
|
+
case 25:
|
|
149
159
|
case "end":
|
|
150
160
|
return _context.stop();
|
|
151
161
|
}
|
|
152
|
-
}, _callee, null, [[
|
|
162
|
+
}, _callee, null, [[6, 11]]);
|
|
153
163
|
}));
|
|
154
164
|
return function (_x, _x2) {
|
|
155
165
|
return _ref2.apply(this, arguments);
|
|
@@ -211,7 +221,7 @@ export var transformColumns = function transformColumns() {
|
|
|
211
221
|
setState = config.setState,
|
|
212
222
|
page = config.page;
|
|
213
223
|
var isCell = mode === 'cell';
|
|
214
|
-
var nextColumns = cloneDeepFilterNode(
|
|
224
|
+
var nextColumns = columns.map(item => cloneDeepFilterNode(item));
|
|
215
225
|
var pageNum = tools.calc(page.pageNum, '-', 1);
|
|
216
226
|
var firstIndex = tools.calc(pageNum, '*', page.pageSize);
|
|
217
227
|
nextColumns.forEach((item, index) => {
|
|
@@ -364,6 +374,51 @@ export var transformColumns = function transformColumns() {
|
|
|
364
374
|
});
|
|
365
375
|
};
|
|
366
376
|
item.render = _render;
|
|
377
|
+
|
|
378
|
+
// 精准控制单元格更新,减少不必要的渲染
|
|
379
|
+
if (!item.shouldCellUpdate) {
|
|
380
|
+
var hasComponent = isFunction(item.component);
|
|
381
|
+
var columnCacheKey = `${Array.isArray(name) ? name.join('.') : String(name)}::${String(columnName)}`;
|
|
382
|
+
item.shouldCellUpdate = (record, prevRecord) => {
|
|
383
|
+
var _item$fieldProps;
|
|
384
|
+
var currentDataSourceRef = !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.dataSource : undefined;
|
|
385
|
+
if (currentDataSourceRef !== undefined) {
|
|
386
|
+
var prevDataSourceRef = columnDataSourceRefCache.get(columnCacheKey);
|
|
387
|
+
if (prevDataSourceRef !== currentDataSourceRef) {
|
|
388
|
+
columnDataSourceRefCache.set(columnCacheKey, currentDataSourceRef);
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if ((record === null || record === void 0 ? void 0 : record.rowKey) !== (prevRecord === null || prevRecord === void 0 ? void 0 : prevRecord.rowKey)) {
|
|
393
|
+
return true;
|
|
394
|
+
}
|
|
395
|
+
// 单行编辑模式下,需要检测编辑状态变化
|
|
396
|
+
if (virtualKey && (record === null || record === void 0 ? void 0 : record._isEditing) !== (prevRecord === null || prevRecord === void 0 ? void 0 : prevRecord._isEditing)) {
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
// 动态 component 可能依赖行内其他字段,需比较整行
|
|
400
|
+
if (hasComponent) {
|
|
401
|
+
// component 函数引用变化说明外部依赖(如异步 list)已更新,必须重渲染
|
|
402
|
+
// 即使行数据未变,旧闭包仍持有过时的外部状态
|
|
403
|
+
var prevComponentRef = columnComponentRefCache.get(columnCacheKey);
|
|
404
|
+
var currentComponentRef = item.component;
|
|
405
|
+
if (prevComponentRef !== currentComponentRef) {
|
|
406
|
+
columnComponentRefCache.set(columnCacheKey, currentComponentRef);
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
// 同引用时 isEqual 恒为 true,无法感知原地修改,必须重渲染
|
|
410
|
+
if (record === prevRecord) {
|
|
411
|
+
return true;
|
|
412
|
+
}
|
|
413
|
+
var rowChanged = !isEqual(record, prevRecord);
|
|
414
|
+
return rowChanged;
|
|
415
|
+
}
|
|
416
|
+
var key = item.dataIndex || item.key;
|
|
417
|
+
if (!key) return true;
|
|
418
|
+
var keyChanged = (record === null || record === void 0 ? void 0 : record[key]) !== (prevRecord === null || prevRecord === void 0 ? void 0 : prevRecord[key]);
|
|
419
|
+
return keyChanged;
|
|
420
|
+
};
|
|
421
|
+
}
|
|
367
422
|
});
|
|
368
423
|
if (disabled || isView) {
|
|
369
424
|
// 查看模式下过滤操作栏
|
|
@@ -8,7 +8,7 @@ import { useRef, useState, useEffect } from 'react';
|
|
|
8
8
|
import { isFunction, isEqualWith, debounce } from 'lodash';
|
|
9
9
|
import { customEqualForFunction } from "../../utils";
|
|
10
10
|
var useShouldUpdateForTable = props => {
|
|
11
|
-
var _isEditableRef$curren, _requiredRef$current, _rulesRef$current, _fieldPropsRef$curren, _desensitizationRef$c, _valueTypeRef$current;
|
|
11
|
+
var _isEditableRef$curren, _requiredRef$current, _rulesRef$current, _fieldPropsRef$curren, _desensitizationRef$c, _valueTypeRef$current, _componentRef$current;
|
|
12
12
|
var rowParams = props.rowParams,
|
|
13
13
|
column = props.column,
|
|
14
14
|
shouldUpdateDebounce = props.shouldUpdateDebounce;
|
|
@@ -20,11 +20,13 @@ var useShouldUpdateForTable = props => {
|
|
|
20
20
|
var fieldPropsRef = useRef();
|
|
21
21
|
var desensitizationRef = useRef();
|
|
22
22
|
var valueTypeRef = useRef();
|
|
23
|
+
var componentRef = useRef();
|
|
23
24
|
var _useState = useState({}),
|
|
24
25
|
_useState2 = _slicedToArray(_useState, 2),
|
|
25
26
|
reRender = _useState2[1];
|
|
26
27
|
var debouncedUpdateRef = useRef(null);
|
|
27
28
|
var pendingParamsRef = useRef(null);
|
|
29
|
+
var isInitializedRef = useRef(false);
|
|
28
30
|
|
|
29
31
|
// 统一处理所有动态属性的更新
|
|
30
32
|
var processUpdate = params => {
|
|
@@ -99,6 +101,19 @@ var useShouldUpdateForTable = props => {
|
|
|
99
101
|
} else {
|
|
100
102
|
valueTypeRef.current = column.valueType;
|
|
101
103
|
}
|
|
104
|
+
|
|
105
|
+
// component 处理(注意:component 是 editRender 的别名)
|
|
106
|
+
var componentOrEditRender = column.component || column.editRender;
|
|
107
|
+
if (isFunction(componentOrEditRender)) {
|
|
108
|
+
var newComponent = componentOrEditRender(values, reactiveParams);
|
|
109
|
+
// 对于 ReactNode 类型的返回值,使用深度比较
|
|
110
|
+
if (!isEqualWith(componentRef.current, newComponent, customEqualForFunction)) {
|
|
111
|
+
componentRef.current = newComponent;
|
|
112
|
+
hasChange = true;
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
componentRef.current = componentOrEditRender;
|
|
116
|
+
}
|
|
102
117
|
if (hasChange) {
|
|
103
118
|
reRender({});
|
|
104
119
|
}
|
|
@@ -106,7 +121,8 @@ var useShouldUpdateForTable = props => {
|
|
|
106
121
|
|
|
107
122
|
// 创建防抖函数(统一处理所有动态属性)
|
|
108
123
|
useEffect(() => {
|
|
109
|
-
|
|
124
|
+
var componentOrEditRender = column.component || column.editRender;
|
|
125
|
+
if (shouldUpdateDebounce > 0 && (isFunction(column.isEditable) || isFunction(column.required) || isFunction(column.rules) || isFunction(column.fieldProps) || isFunction(column.desensitization) || isFunction(column.valueType) || isFunction(componentOrEditRender))) {
|
|
110
126
|
debouncedUpdateRef.current = debounce(() => {
|
|
111
127
|
if (pendingParamsRef.current) {
|
|
112
128
|
processUpdate(pendingParamsRef.current);
|
|
@@ -121,13 +137,23 @@ var useShouldUpdateForTable = props => {
|
|
|
121
137
|
}, [shouldUpdateDebounce, column]);
|
|
122
138
|
|
|
123
139
|
// 统一的属性处理逻辑
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
// 使用 ref 存储上一次的 rowParams,避免引用变化导致的重复调用
|
|
141
|
+
var prevRowParamsRef = useRef(null);
|
|
142
|
+
|
|
143
|
+
// 只有当 rowParams 内容真正变化时才处理更新
|
|
144
|
+
// 或者是第一次初始化
|
|
145
|
+
var shouldProcess = !isInitializedRef.current || !isEqualWith(prevRowParamsRef.current, rowParams, customEqualForFunction);
|
|
146
|
+
if (shouldProcess) {
|
|
147
|
+
prevRowParamsRef.current = rowParams;
|
|
148
|
+
isInitializedRef.current = true;
|
|
149
|
+
if (shouldUpdateDebounce > 0 && debouncedUpdateRef.current) {
|
|
150
|
+
// 使用防抖延迟更新
|
|
151
|
+
pendingParamsRef.current = rowParams;
|
|
152
|
+
debouncedUpdateRef.current();
|
|
153
|
+
} else {
|
|
154
|
+
// 立即更新(shouldUpdateDebounce = 0 或无防抖函数)
|
|
155
|
+
processUpdate(rowParams);
|
|
156
|
+
}
|
|
131
157
|
}
|
|
132
158
|
return {
|
|
133
159
|
isEditable: (_isEditableRef$curren = isEditableRef.current) !== null && _isEditableRef$curren !== void 0 ? _isEditableRef$curren : column.isEditable,
|
|
@@ -135,7 +161,8 @@ var useShouldUpdateForTable = props => {
|
|
|
135
161
|
rules: (_rulesRef$current = rulesRef.current) !== null && _rulesRef$current !== void 0 ? _rulesRef$current : column.rules,
|
|
136
162
|
fieldProps: (_fieldPropsRef$curren = fieldPropsRef.current) !== null && _fieldPropsRef$curren !== void 0 ? _fieldPropsRef$curren : column.fieldProps,
|
|
137
163
|
desensitization: (_desensitizationRef$c = desensitizationRef.current) !== null && _desensitizationRef$c !== void 0 ? _desensitizationRef$c : column.desensitization,
|
|
138
|
-
valueType: (_valueTypeRef$current = valueTypeRef.current) !== null && _valueTypeRef$current !== void 0 ? _valueTypeRef$current : column.valueType
|
|
164
|
+
valueType: (_valueTypeRef$current = valueTypeRef.current) !== null && _valueTypeRef$current !== void 0 ? _valueTypeRef$current : column.valueType,
|
|
165
|
+
component: (_componentRef$current = componentRef.current) !== null && _componentRef$current !== void 0 ? _componentRef$current : column.component || column.editRender
|
|
139
166
|
};
|
|
140
167
|
};
|
|
141
168
|
export default useShouldUpdateForTable;
|
|
@@ -87,13 +87,7 @@ var DatePicker = props => {
|
|
|
87
87
|
restProps.showTime = true;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
// onChange
|
|
91
|
-
var handleChange = (date, dateString) => {
|
|
92
|
-
var _rest$onChange;
|
|
93
|
-
var valueToStore = date && typeof nextFormat === 'string' ? date.format(nextFormat) : date;
|
|
94
|
-
(_rest$onChange = rest.onChange) === null || _rest$onChange === void 0 || _rest$onChange.call(rest, valueToStore, dateString);
|
|
95
|
-
};
|
|
96
|
-
restProps.onChange = handleChange;
|
|
90
|
+
// 直接透传 onChange,保持 dayjs 对象类型(与 RangePicker 一致)
|
|
97
91
|
|
|
98
92
|
// 字符串时间格式兼容,使用 nextFormat 解析 quarter/week 等格式
|
|
99
93
|
if (isString(restProps.value)) {
|